示例#1
0
    def write_event(self, pyev):
        "Write an event.Event object to the ROOT tree as a ROOT.Event object."
        self.ev.id = pyev.id

        if pyev.primary_vertex is not None:
            self.ev.primary_vertex.particle_name = \
                pyev.primary_vertex.particle_name
            self.ev.primary_vertex.pos.SetXYZ(*pyev.primary_vertex.pos)
            self.ev.primary_vertex.dir.SetXYZ(*pyev.primary_vertex.dir)
            if pyev.primary_vertex.pol is not None:
                self.ev.primary_vertex.pol.SetXYZ(*pyev.primary_vertex.pol)
            self.ev.primary_vertex.ke = pyev.primary_vertex.ke
            self.ev.primary_vertex.t0 = pyev.primary_vertex.t0

        if pyev.photons_beg is not None:
            photons = pyev.photons_beg
            ROOT.fill_photons(self.ev.photons_beg,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags)

        if pyev.photons_end is not None:
            photons = pyev.photons_end
            ROOT.fill_photons(self.ev.photons_end,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags)

        self.ev.vertices.resize(0)
        if pyev.vertices is not None:
            self.ev.vertices.resize(len(pyev.vertices))
            for i, vertex in enumerate(pyev.vertices):
                self.ev.vertices[i].particle_name = vertex.particle_name
                self.ev.vertices[i].pos.SetXYZ(*vertex.pos)
                self.ev.vertices[i].dir.SetXYZ(*vertex.dir)
                if vertex.pol is not None:
                    self.ev.vertices[i].pol.SetXYZ(*vertex.pol)
                self.ev.vertices[i].ke = vertex.ke
                self.ev.vertices[i].t0 = vertex.t0

        if pyev.channels is not None:
            nhit = count_nonzero(pyev.channels.hit)
            if nhit > 0:
                ROOT.fill_channels(self.ev, nhit, np.arange(len(pyev.channels.t))[pyev.channels.hit].astype(np.uint32), pyev.channels.t, pyev.channels.q, pyev.channels.flags, len(pyev.channels.hit))
            else:
                self.ev.nhit = 0
                self.ev.channels.resize(0)
                self.ev.nchannels = len(pyev.channels.hit)
        else:
            self.ev.nhit = 0
            self.ev.channels.resize(0)
            self.ev.nchannels = 0

        self.T.Fill()
示例#2
0
文件: root.py 项目: jhualberta/chroma
    def write_event(self, pyev):
        "Write an event.Event object to the ROOT tree as a ROOT.Event object."
        self.ev.id = pyev.id

        if pyev.photons_beg is not None:
            photons = pyev.photons_beg
            ROOT.fill_photons(self.ev.photons_beg, len(photons.pos),
                              photons.pos.ravel(), photons.dir.ravel(),
                              photons.pol.ravel(), photons.wavelengths,
                              photons.t, photons.last_hit_triangles,
                              photons.flags)

        if pyev.photons_end is not None:
            photons = pyev.photons_end
            ROOT.fill_photons(self.ev.photons_end, len(photons.pos),
                              photons.pos.ravel(), photons.dir.ravel(),
                              photons.pol.ravel(), photons.wavelengths,
                              photons.t, photons.last_hit_triangles,
                              photons.flags)

        self.ev.vertices.resize(0)
        if pyev.vertices is not None:
            self.ev.vertices.resize(len(pyev.vertices))
            for i, vertex in enumerate(pyev.vertices):
                python_vertex_to_root_vertex(vertex, self.ev.vertices[i])

        if pyev.channels is not None:
            nhit = count_nonzero(pyev.channels.hit)
            if nhit > 0:
                ROOT.fill_channels(
                    self.ev, nhit,
                    np.arange(len(pyev.channels.t))[pyev.channels.hit].astype(
                        np.uint32), pyev.channels.t, pyev.channels.q,
                    pyev.channels.flags, len(pyev.channels.hit))
            else:
                self.ev.nhit = 0
                self.ev.channels.resize(0)
                self.ev.nchannels = len(pyev.channels.hit)
        else:
            self.ev.nhit = 0
            self.ev.channels.resize(0)
            self.ev.nchannels = 0

        self.T.Fill()
示例#3
0
文件: root.py 项目: BenLand100/chroma
    def write_event(self, pyev):
        "Write an event.Event object to the ROOT tree as a ROOT.Event object."
        self.ev.id = pyev.id

        if pyev.photons_beg is not None:
            photons = pyev.photons_beg
            ROOT.fill_photons(self.ev.photons_beg,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags)

        if pyev.photons_end is not None:
            photons = pyev.photons_end
            ROOT.fill_photons(self.ev.photons_end,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags)

        self.ev.vertices.resize(0)
        if pyev.vertices is not None:
            self.ev.vertices.resize(len(pyev.vertices))
            for i, vertex in enumerate(pyev.vertices):
                python_vertex_to_root_vertex(vertex,self.ev.vertices[i])

        if pyev.channels is not None:
            nhit = count_nonzero(pyev.channels.hit)
            if nhit > 0:
                ROOT.fill_channels(self.ev, nhit, np.arange(len(pyev.channels.t))[pyev.channels.hit].astype(np.uint32), pyev.channels.t, pyev.channels.q, pyev.channels.flags, len(pyev.channels.hit))
            else:
                self.ev.nhit = 0
                self.ev.channels.resize(0)
                self.ev.nchannels = len(pyev.channels.hit)
        else:
            self.ev.nhit = 0
            self.ev.channels.resize(0)
            self.ev.nchannels = 0

        self.T.Fill()
示例#4
0
    def write_event(self, pyev):
        "Write an event.Event object to the ROOT tree as a ROOT.Event object."
        self.ev.id = pyev.id

        if pyev.photons_beg is not None:
            photons = pyev.photons_beg
            ROOT.fill_photons(self.ev.photons_beg,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.flags)

        if pyev.photons_end is not None:
            photons = pyev.photons_end
            ROOT.fill_photons(self.ev.photons_end,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.flags)

        self.T.Fill()
示例#5
0
    def write_event(self, pyev):
        "Write an event.Event object to the ROOT tree as a ROOT.Event object."
        self.ev.id = pyev.id
        
        if pyev.photons_beg is not None:
            photons = pyev.photons_beg
            if len(photons.pos) > 0:
                ROOT.fill_photons(self.ev.photons_beg,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags, 
                              photons.channel)
        else:
            self.ev.photons_beg.resize(0)

        if pyev.photons_end is not None:
            photons = pyev.photons_end
            if len(photons.pos) > 0:
                ROOT.fill_photons(self.ev.photons_end,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags, 
                              photons.channel)
        else:
            self.ev.photons_end.resize(0)
        
        if pyev.photon_tracks is not None:
            self.ev.photon_tracks.resize(len(pyev.photon_tracks))
            for i in range(len(pyev.photon_tracks)):
                photons = pyev.photon_tracks[i]
                if len(photons.pos) > 0:
                    ROOT.fill_photons(self.ev.photon_tracks[i],
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags, 
                              photons.channel)
            self.ev.photon_parent_trackids.resize(len(pyev.photon_parent_trackids))
            np.asarray(self.ev.photon_parent_trackids)[:] = pyev.photon_parent_trackids
        else:
            self.ev.photon_tracks.resize(0)
            self.ev.photon_parent_trackids.resize(0)
        
        if pyev.vertices is not None:
            self.ev.vertices.resize(len(pyev.vertices))
            for i, vertex in enumerate(pyev.vertices):
                python_vertex_to_root_vertex(vertex,self.ev.vertices[i])
        else:
            self.ev.vertices.resize(0)
        
        if pyev.hits is not None:
            self.ev.hits.clear()
            for hit in pyev.hits:
                photons = pyev.hits[hit]
                if len(photons.pos) > 0:
                    ROOT.fill_photons(self.ev.hits[hit],len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags, 
                              photons.channel)
        else:
            self.ev.hits.clear()
        
        if pyev.flat_hits is not None:
            photons = pyev.flat_hits
            if len(photons.pos) > 0:
                ROOT.fill_photons(self.ev.flat_hits,
                              len(photons.pos),
                              photons.pos.ravel(),
                              photons.dir.ravel(),
                              photons.pol.ravel(),
                              photons.wavelengths, photons.t,
                              photons.last_hit_triangles, photons.flags, 
                              photons.channel)
        else:
            self.ev.flat_hits.resize(0)
        
        if pyev.channels is not None:
            hit_channels = pyev.channels.hit.nonzero()[0].astype(np.uint32)
            if len(hit_channels) > 0:
                ROOT.fill_channels(self.ev, len(hit_channels), hit_channels, 
                                   len(pyev.channels.hit), 
                                   pyev.channels.t.astype(np.float32), 
                                   pyev.channels.q.astype(np.float32), 
                                   pyev.channels.flags.astype(np.uint32))
            else:
                self.ev.nhit = 0
                self.ev.nchannels = 0
                self.ev.channels.resize(0)
        else:
            self.ev.nhit = 0
            self.ev.nchannels = 0
            self.ev.channels.resize(0)

        self.T.Fill()