~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/common_py/MausReducedData/SciFiReducedData.py

merging in changes in merge branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# pylint: disable = R0914
15
15
# pylint: disable = R0915
16
16
 
17
 
class TOF:
18
 
    """ Class holding reduced data for one TOF detector
19
 
        Uses arrays to make compatible with ROOT plotting.
20
 
        May accumulate data over many events. """
21
 
 
22
 
    def __init__(self):
23
 
        """ Constructor, set everything to empty or zero """
24
 
        self.tof_num = 0
25
 
        self.num_spoints = 0
26
 
        self.spoints_global_x = array.array('d')
27
 
        self.spoints_global_y = array.array('d')
28
 
        self.spoints_global_z = array.array('d')
29
 
 
30
 
    def accumulate_data(self, evt, tof_num):
31
 
        """ Add data from an event """
32
 
        self.tof_num = tof_num
33
 
        if self.tof_num == 0:
34
 
            spoints = evt.GetTOFEventSpacePoint().GetTOF0SpacePointArray()
35
 
        elif self.tof_num == 1:
36
 
            spoints = evt.GetTOFEventSpacePoint().GetTOF1SpacePointArray()
37
 
        elif self.tof_num == 2:
38
 
            spoints = evt.GetTOFEventSpacePoint().GetTOF2SpacePointArray()
39
 
        for sp in spoints:
40
 
            x = sp.GetGlobalPosX()
41
 
            y = sp.GetGlobalPosY()
42
 
            z = sp.GetGlobalPosZ()
43
 
            self.spoints_global_x.append(x)
44
 
            self.spoints_global_y.append(y)
45
 
            self.spoints_global_z.append(z)
46
 
            self.num_spoints += 1
47
 
 
48
 
    def clear(self):
49
 
        """ Clear all accumulated data """
50
 
        self.tof_num = 0
51
 
        self.num_spoints = 0
52
 
        self.spoints_global_x = array.array('d')
53
 
        self.spoints_global_y = array.array('d')
54
 
        self.spoints_global_z = array.array('d')
55
 
 
56
17
class Tracker:
57
18
    """ Class holding data for one tracker.
58
19
        Uses arrays to make compatible with ROOT plotting.
94
55
        self.tpoints_global_px = array.array('d')
95
56
        self.tpoints_global_py = array.array('d')
96
57
        self.tpoints_global_pz = array.array('d')
 
58
        self.tpoints_plane = array.array('d')
 
59
        self.tpoints_station = array.array('d')
97
60
        # Pat Rec track fits
98
61
        self.straight_xz_fits = []
99
62
        self.straight_yz_fits = []
 
63
        self.straight_global_xz_fits = []
 
64
        self.straight_global_yz_fits = []
100
65
        self.helix_xy_fits = []
101
66
        self.helix_xz_fits = []
102
67
        self.helix_yz_fits = []
145
110
                mx = trk.get_mx()
146
111
                y0 = trk.get_y0()
147
112
                my = trk.get_my()
 
113
                gx0 = trk.get_global_x0()
 
114
                gmx = trk.get_global_mx()
 
115
                gy0 = trk.get_global_y0()
 
116
                gmy = trk.get_global_my()
 
117
 
 
118
                self.straight_xz_fits.append(self.make_line(mx, x0, 0, 1200))
 
119
                self.straight_yz_fits.append(self.make_line(my, y0, 0, 1200))
 
120
                zmin = 12800
 
121
                zmax = 22000
148
122
                if trker_num == 0:
149
 
                    self.straight_xz_fits.append(self.make_line(mx, x0, \
150
 
                                                                 0, 1200))
151
 
                    self.straight_yz_fits.append(self.make_line(my, y0, \
152
 
                                                                 0, 1200))
 
123
                    zmin = 12800
 
124
                    zmax = 15200
153
125
                else:
154
 
                    self.straight_xz_fits.append(self.make_line(mx, x0, \
155
 
                                                                 0, 1200))
156
 
                    self.straight_yz_fits.append(self.make_line(my, y0, \
157
 
                                                                 0, 1200))
 
126
                    zmin = 18800
 
127
                    zmax = 21200
 
128
                self.straight_global_xz_fits.append(
 
129
                  self.make_line(gmx, gx0, zmin, zmax))
 
130
                self.straight_global_yz_fits.append(
 
131
                  self.make_line(gmy, gy0, zmin, zmax))
158
132
                # Pull out the coords of each seed spacepoint
159
133
                x_per_trk = array.array('d')
160
134
                y_per_trk = array.array('d')
269
243
                px_per_trk = array.array('d')
270
244
                py_per_trk = array.array('d')
271
245
                pz_per_trk = array.array('d')
 
246
                plane_per_trk = array.array('d')
 
247
                station_per_trk = array.array('d')
272
248
                for tp in tpoints:
273
249
                    x_per_trk.append(tp.pos().x())
274
250
                    y_per_trk.append(tp.pos().y())
276
252
                    px_per_trk.append(tp.mom().x())
277
253
                    py_per_trk.append(tp.mom().y())
278
254
                    pz_per_trk.append(tp.mom().z())
 
255
                    plane_per_trk.append(tp.plane())
 
256
                    station_per_trk.append(tp.station())
279
257
                self.tpoints_global_x.extend(x_per_trk)
280
258
                self.tpoints_global_y.extend(y_per_trk)
281
259
                self.tpoints_global_z.extend(z_per_trk)
282
260
                self.tpoints_global_px.extend(px_per_trk)
283
261
                self.tpoints_global_py.extend(py_per_trk)
284
262
                self.tpoints_global_pz.extend(pz_per_trk)
 
263
                self.tpoints_plane.extend(plane_per_trk)
 
264
                self.tpoints_station.extend(station_per_trk)
285
265
 
286
266
    @staticmethod
287
267
    def make_circle(x0, y0, rad):
295
275
    def make_helix_xz(circle_x0, rad, dsdz, sz_c, zmin, zmax):
296
276
        """ Make a function for the x-z projection of the helix """
297
277
        # The x in the cos term is actually representing z (the indep variable)
298
 
        func = ROOT.TF1("xz_func", "[0]-([1]*cos((1/[1])*([2]*x+[3])))", \
 
278
        func = ROOT.TF1("xz_func", "[0]+([1]*cos((1/[1])*([2]*x+[3])))", \
299
279
                        zmin, zmax)
300
280
        func.SetParameter(0, circle_x0)
301
281
        func.SetParameter(1, rad)