Esempio n. 1
0
 def find_beam_interruptions(self, bin_width=10, threshold=.4):
     """ Looking for beam interruptions by evaluating the event rate. """
     bin_values, time_bins = histogram(
         self.Run.Time / 1000,
         bins=Bins(self.Ana).get_raw_time(bin_width)[1])
     m = mean(
         bin_values[bin_values.argsort()][-20:-10]
     )  # take the mean of the 20th to the 10th highest bin to get an estimate of the plateau
     deviating_bins = where(abs(1 - bin_values / m) > threshold)[0]
     times = time_bins[deviating_bins] + bin_width / 2 - self.Run.Time[
         0] / 1000  # shift to the center of the bin
     not_connected = where(
         concatenate([[False], deviating_bins[:-1] != deviating_bins[1:] - 1
                      ]))[0]  # find the bins that are not consecutive
     times = split(times, not_connected)
     interruptions = [[
         self.get_event_at_time(v, rel=True) for v in [t[0], t[-1]]
     ] for t in times] if len(times[0]) else []
     return interruptions
Esempio n. 2
0
    def __init__(self,
                 run_number,
                 diamond_nr=1,
                 testcampaign=None,
                 load_tree=None,
                 verbose=False,
                 prnt=True):

        self.Run = self.init_run(run_number, testcampaign, load_tree, verbose)
        self.DUT = self.Run.DUTs[diamond_nr - 1]
        super(DUTAnalysis, self).__init__(testcampaign,
                                          sub_dir=join(self.DUT.Name,
                                                       str(self.Run.Number)),
                                          verbose=verbose)

        self.Tree = self.Run.Tree
        self.StartTime = self.Run.StartTime if self.Tree.Hash(
        ) else time_stamp(self.Run.LogStart)

        self.print_start(run_number, prnt, dut=self.DUT.Name)
        self.update_config()

        # Sub-Analyses
        self.Currents = Currents(self)

        if self.Tree.Hash():
            self.NRocs = self.Run.NPlanes
            self.Cut = self.init_cut()
            self.StartEvent = self.Cut.get_min_event()
            self.EndEvent = self.Cut.get_max_event()
            self.Bins = Bins(self)
            self.Tracks = Tracks(self)
            self.Tel = Telescope(self)

            # alignment
            self.Alignment = None
            self.IsAligned = self.check_alignment()