Esempio n. 1
0
 def test_unpack_nfirst(self):
     a_tuple = (1, 2, 3, 4, 5)
     a, b, c, rest = unpack_nfirst(a_tuple, 3)
     self.assertEqual(1, a)
     self.assertEqual(2, b)
     self.assertEqual(3, c)
     self.assertTupleEqual((4, 5), rest)
Esempio n. 2
0
 def test_unpack_nfirst_callback(self):
     a_string = "12345"
     a, b, c, rest = unpack_nfirst(a_string, 3, callback=int)
     self.assertEqual(1, a)
     self.assertEqual(2, b)
     self.assertEqual(3, c)
     self.assertTupleEqual(("4", "5"), rest)
Esempio n. 3
0
 def test_unpack_nfirst(self):
     a_tuple = (1, 2, 3, 4, 5)
     a, b, c, rest = unpack_nfirst(a_tuple, 3)
     self.assertEqual(1, a)
     self.assertEqual(2, b)
     self.assertEqual(3, c)
     self.assertTupleEqual((4, 5), rest)
Esempio n. 4
0
 def __init__(self, data, zed_correction=405.93):
     id, x, y, z, dx, dy, dz, E, t, args = unpack_nfirst(data, 9)
     self.id = int(id)
     # z correctio due to gen/km3 (ZED -> sea level shift)
     # http://wiki.km3net.physik.uni-erlangen.de/index.php/Simulations
     self.pos = Point((x, y, z + zed_correction))
     self.dir = Direction((dx, dy, dz))
     self.E = E
     self.time = t
     self.args = args
Esempio n. 5
0
 def parse_doms(self):
     """Extract dom information from detector file"""
     self.det_file.seek(0, 0)
     self.det_file.readline()
     lines = self.det_file.readlines()
     try:
         while True:
             line = lines.pop(0)
             if not line:
                 continue
             try:
                 dom_id, line_id, floor_id, n_pmts = split(line, int)
             except ValueError:
                 continue
             self.n_pmts_per_dom = n_pmts
             for i in range(n_pmts):
                 raw_pmt_info = lines.pop(0)
                 pmt_info = raw_pmt_info.split()
                 pmt_id, x, y, z, rest = unpack_nfirst(pmt_info, 4)
                 dx, dy, dz, t0, rest = unpack_nfirst(rest, 4)
                 if rest:
                     log.warn("Unexpected PMT values: '{0}'".format(rest))
                 pmt_id = int(pmt_id)
                 pmt_pos = [float(n) for n in (x, y, z)]
                 pmt_dir = [float(n) for n in (dx, dy, dz)]
                 t0 = float(t0)
                 if floor_id < 0:
                     _, new_floor_id, _ = self.pmtid2omkey_old(pmt_id)
                     log.error("Floor ID is negative for PMT {0}.\n"
                               "Guessing correct id: {1}"
                               .format(pmt_id, new_floor_id))
                     floor_id = new_floor_id
                 #TODO: following line is here bc of the bad MC floor IDs
                 #      put it outside the for loop in future
                 self.doms[dom_id] = (line_id, floor_id, n_pmts)
                 omkey = (line_id, floor_id, i)
                 pmt = PMT(pmt_id, pmt_pos, pmt_dir, t0, i, omkey)
                 self.pmts.append(pmt)
                 self._pmts_by_omkey[(line_id, floor_id, i)] = pmt
                 self._pmts_by_id[pmt_id] = pmt
     except IndexError:
         pass
Esempio n. 6
0
 def __init__(self, data, zed_correction=405.93):
     id, x, y, z, dx, dy, dz, E, t, Bx, By, \
         ichan, particle_type, channel, args = unpack_nfirst(data, 14)
     self.id = id
     # z correctio due to gen/km3 (ZED -> sea level shift)
     # http://wiki.km3net.physik.uni-erlangen.de/index.php/Simulations
     self.pos = Point((x, y, z + zed_correction))
     self.dir = Direction((dx, dy, dz))
     self.E = E
     self.time = t
     self.Bx = Bx
     self.By = By
     self.ichan = ichan
     self.particle_type = particle_type
     self.channel = channel