Beispiel #1
0
    def build_peak(self, hits, detector, **kwargs):
        """Return a peak object made from hits. Compute a few basic properties which are needed during the clustering
        stages.
        Any kwargs will be passed to the peak constructor.
        """
        hits.sort(order='index_of_maximum'
                  )  # Hits must always be in sorted time order

        peak = Peak(detector=detector, hits=hits, **kwargs)

        peak.area_per_channel = dsputils.count_hits_per_channel(
            peak, self.config, weights=hits['area'])
        peak.n_contributing_channels = np.sum(peak.does_channel_contribute)

        if peak.n_contributing_channels == 0:
            raise RuntimeError(
                "Every peak should have at least one contributing channel... what's going on?"
            )

        if peak.n_contributing_channels == 1:
            peak.type = 'lone_hit'
            peak.lone_hit_channel = hits[0]['channel']

        peak.area = peak.area_per_channel.sum()
        peak.left = peak.hits[0]['left']
        peak.right = peak.hits['right'].max()

        return peak
Beispiel #2
0
    def test_s1_helper_method(self):
        e = Event.empty_event()
        e.peaks.append(Peak({'area': 2.0,
                             'index_of_maximum': 0,
                             'type': 's1',
                             'detector':         'tpc', }))

        self.assertEqual(len(e.S1s()), 1)
        self.assertIsInstance(e.S1s()[0], Peak)
        self.assertEqual(e.S1s()[0].area, 2.0)
Beispiel #3
0
    def test_peaks_append(self):
        e = Event.empty_event()
        e.peaks.append(Peak({'area': 2.0,
                             'index_of_maximum': 0,
                             'type': 'S1',
                             'detector':         'tpc'}))

        self.assertEqual(len(e.peaks), 1)
        self.assertIsInstance(e.peaks[0], Peak)
        self.assertEqual(e.peaks[0].area, 2.0)
Beispiel #4
0
    def test_peaks(self):
        e = Event.empty_event()
        e.peaks = [Peak(
            area=0,
            index_of_maximum=0,
            detector='tpc')]

        self.assertEqual(len(e.peaks), 1)
        self.assertIsInstance(e.peaks[0], Peak)
        self.assertEqual(e.peaks[0].area, 0)
Beispiel #5
0
 def example_event(channels_with_something):
     bla = np.zeros(242)
     bla[np.array(channels_with_something)] = 1
     e = Event.empty_event()
     e.peaks.append(
         Peak({
             'left': 5,
             'right': 9,
             'type': 'unknown',
             'detector': 'tpc',
             'area_per_channel': bla,
         }))
     return e
Beispiel #6
0
 def example_event(self, channels_with_something):
     channels = np.array(channels_with_something, dtype='float64')
     e = Event.empty_event()
     e.peaks.append(
         Peak({
             'left': 5,
             'right': 9,
             'type': 'S2',
             'detector': 'tpc',
             'area': 123,
             'area_per_channel': channels
         }))
     return e
Beispiel #7
0
    def setUp(self):  # noqa
        self.pax = core.Processor(config_names='XENON100',
                                  just_testing=True,
                                  config_dict={
                                      'pax': {
                                          'plugin_group_names': ['test'],
                                          'test':
                                          'WeightedSum.PosRecWeightedSum'
                                      }
                                  })
        self.posrec_plugin = self.pax.get_plugin_by_name('PosRecWeightedSum')

        self.e = Event.empty_event()

        self.e.peaks.append(Peak({'left': 5, 'right': 9, 'type': 's2'}))
Beispiel #8
0
    def test_s1_helper_method_sort(self):
        areas = [3.0, 1.0, 2.0, 1.2]

        e = Event.empty_event()
        for area in areas:
            e.peaks.append(Peak({'area': area,
                                 'type': 's2',
                                 'detector': 'tpc'}))

        s2s = e.S2s()
        self.assertEqual(len(s2s), len(areas))

        # Please note the areas should come out in reverse order (largest first)
        areas = sorted(areas, reverse=True)

        for i, area in enumerate(areas):
            self.assertIsInstance(s2s[i], Peak)
            self.assertEqual(s2s[i].area, area)
Beispiel #9
0
 def example_event():
     top_hits = [
         7, 8, 8, 5, 8, 10, 6, 9, 3, 7, 6, 4, 5, 2, 1, 0, 7, 1, 3, 1, 4, 2,
         5, 1, 4, 3, 1, 3, 2, 4, 3, 0, 4, 4, 1, 6, 2, 4, 9, 12, 8, 10, 9, 6,
         9, 1, 2, 1, 2, 1, 4, 10, 0, 0, 1, 2, 1, 0, 2, 3, 6, 1, 3, 2, 3, 5,
         2, 6, 30, 18, 24, 10, 8, 3, 4, 2, 4, 2, 1, 4, 3, 4, 5, 5, 2, 1, 2,
         2, 2, 4, 12, 48, 139, 89, 19, 9, 3, 4, 2, 3, 1, 1, 6, 0, 3, 1, 2,
         4, 12, 97, 87, 15, 6, 3, 4, 4, 0, 2, 3, 6, 13, 21, 3, 4, 3, 1, 7
     ]
     hits = np.append(top_hits, np.zeros(254 - 127))
     e = Event.empty_event()
     e.peaks.append(
         Peak({
             'left': 5,
             'right': 9,
             'type': 'S2',
             'detector': 'tpc',
             'area': 123,
             'area_per_channel': hits
         }))
     return e
Beispiel #10
0
    def build_peak(self, hits, detector, **kwargs):
        """Return a peak object made from hits. Compute a few basic properties which are needed during the clustering
        stages.
        Any kwargs will be passed to the peak constructor.
        """
        hits.sort(order='left_central')     # Hits must always be in sorted time order

        peak = Peak(detector=detector, hits=hits, **kwargs)

        peak.area_per_channel = dsputils.count_hits_per_channel(peak, self.config, weights=hits['area'])
        peak.n_contributing_channels = np.sum(peak.does_channel_contribute)

        if peak.n_contributing_channels == 0:
            raise RuntimeError("Every peak should have at least one contributing channel... what's going on?")

        if peak.n_contributing_channels == 1:
            peak.type = 'lone_hit'
            peak.lone_hit_channel = hits[0]['channel']

        peak.area = peak.area_per_channel.sum()
        peak.left = peak.hits[0]['left']
        peak.right = peak.hits['right'].max()

        return peak
Beispiel #11
0
 def example_event():
     # Hitpattern taken from "S2_5e3Phts_1e5Evts.root"
     # MC truth (x,y) = (100.833, 177.593) [mm]
     # Recontructed by Yuehuans c++/ROOT code at (102.581, 177.855) [mm]
     # Reconstucted by the PAX implementation at (10.258076101568305 17.785535721706857) [cm]
     top_hits = [
         7, 8, 8, 5, 8, 10, 6, 9, 3, 7, 6, 4, 5, 2, 1, 0, 7, 1, 3, 1, 4, 2,
         5, 1, 4, 3, 1, 3, 2, 4, 3, 0, 4, 4, 1, 6, 2, 4, 9, 12, 8, 10, 9, 6,
         9, 1, 2, 1, 2, 1, 4, 10, 0, 0, 1, 2, 1, 0, 2, 3, 6, 1, 3, 2, 3, 5,
         2, 6, 30, 18, 24, 10, 8, 3, 4, 2, 4, 2, 1, 4, 3, 4, 5, 5, 2, 1, 2,
         2, 2, 4, 12, 48, 139, 89, 19, 9, 3, 4, 2, 3, 1, 1, 6, 0, 3, 1, 2,
         4, 12, 97, 87, 15, 6, 3, 4, 4, 0, 2, 3, 6, 13, 21, 3, 4, 3, 1, 7
     ]
     hits = np.append(top_hits, np.zeros(254 - 127))
     e = Event.empty_event()
     e.peaks.append(
         Peak({
             'left': 5,
             'right': 9,
             'type': 'S2',
             'detector': 'tpc',
             'area_per_channel': hits
         }))
     return e
Beispiel #12
0
 def test_peak_instantiation(self):
     p = Peak({'area': 3.0,
               'index_of_maximum': 0,
               'detector':         'tpc', })
     self.assertIsInstance(p, Peak)
     self.assertEqual(p.area, 3.0)