Пример #1
0
 def __str__(self):
     text = "Neutrino: "
     text += pdg2name(self.particle_type)
     if self.E >= 1000000:
         text += ", {0:.3} PeV".format(self.E / 1000000)
     elif self.E >= 1000:
         text += ", {0:.3} TeV".format(self.E / 1000)
     else:
         text += ", {0:.3} GeV".format(float(self.E))
     text += ', CC' if int(self.channel) == 2 else ', NC'
     return text
Пример #2
0
    def initialise_spectrum(self, blob, style="default"):

        if style == 'default':
            hits = self.extract_hits(blob)
            hits = self.remove_hidden_hits(hits)

            hit_times = []
            #step_size = int(len(hits) / 100) + 1
            for hit in hits:
                if hit.time > 0:
                    hit_times.append(hit.time)

            if len(hit_times) == 0:
                log.warn("No hits left after applying cuts.")
                return

            self.min_hit_time = min(hit_times)
            self.max_hit_time = max(hit_times)

            def spectrum(time, hit=None):
                min_time = min(hit_times)
                max_time = max(hit_times)
                diff = max_time - min_time
                one_percent = diff/100
                try:
                    progress = (time - min_time) / one_percent / 100
                except ZeroDivisionError:
                    progress = 0
                return tuple(self.cmap(progress))[:3]
            self.spectrum = spectrum

        if style == 'time_residuals':
            try:
                track_ins = blob['TrackIns']
            except KeyError:
                log.error("No tracks found to determine Cherenkov parameters!")
                self.current_spectrum = "default"
                return
            most_energetic_muon = max(track_ins, key=lambda t: t.E)
            if not pdg2name(most_energetic_muon.particle_type) in ['mu-', 'mu+']:
                log.error("No muon found to determine Cherenkov parameters!")
                self.current_spectrum = "default"
                return

            vertex_pos = most_energetic_muon.pos
            muon_dir = most_energetic_muon.dir

            hits = self.extract_hits(blob)
            hits = self.first_om_hits(hits)

            def cherenkov_time(pmt_pos):
                """Calculates Cherenkov arrival time in [ns]"""
                v = pmt_pos - vertex_pos
                l = v.dot(muon_dir)
                k = np.sqrt(v.dot(v) - l**2)
                v_g = constants.c_water_antares
                theta = constants.theta_cherenkov_water_antares
                t_cherenkov = 1/constants.c * (l - k/np.tan(theta)) + 1 /v_g * k/np.sin(theta)
                return t_cherenkov * 1e9

            self.min_hit_time = -100
            self.max_hit_time = 100

            def spectrum(time, hit=None):
                if hit:
                    pmt_pos = self.detector.pmt_with_id(hit.pmt_id).pos
                    if not hit.t_cherenkov:
                        t_cherenkov = cherenkov_time(pmt_pos)
                        hit.t_cherenkov = t_cherenkov
                        log.debug("Hit time: {0}, Expected: {1}, Time Residual: {2}"
                              .format(time, t_cherenkov, time - t_cherenkov))
                    time = time - hit.t_cherenkov

                diff = self.max_hit_time - self.min_hit_time
                one_percent = diff/100
                try:
                    progress = (time - self.min_hit_time) / one_percent / 100
                    if progress > 1:
                        progress = 1
                except ZeroDivisionError:
                    progress = 0
                return tuple(self.cmap(progress))[:3]
            self.spectrum = spectrum
Пример #3
0
 def test_pdg2name_returns_NA_for_unknown_particle(self):
     self.assertEqual('N/A', pdg2name(0))
Пример #4
0
 def test_pdg2name(self):
     self.assertEqual('mu-', pdg2name(13))
     self.assertEqual('anu_tau', pdg2name(-16))
Пример #5
0
 def __repr__(self):
     text = super(self.__class__, self).__repr__()
     text += " type: {0} '{1}' [PDG]\n".format(self.particle_type,
                                               pdg2name(self.particle_type))
     text += " length: {0} [m]\n".format(self.length)
     return text