Esempio n. 1
0
    def testDiscriminatorStressTest(self):

        #Choosing an arbitrary DOM that we know exists in the detector configuration.
        omKey = icetray.OMKey(42, 2)
        geo = self.frame["I3Geometry"].omgeo
        cal = self.frame["I3Calibration"].dom_cal
        stat = self.frame["I3DetectorStatus"].dom_status

        dom = DOMLauncher.I3InIceDOM(self.random_service, omKey)
        dom.configure(cal[omKey], stat[omKey])

        for n in range(0, 10):
            pulses = simclasses.I3MCPulseSeries()
            pulse = simclasses.I3MCPulse()
            dcstream = DOMLauncher.DCStream()
            #print(n)
            last = 0
            for n in range(0, 2000):
                pulse.charge = 1
                pulse.time = last + np.random.uniform(31, 2000)
                last = pulse.time
                pulses.append(pulse)

            dom.discriminator(pulses, dcstream)
            #print(len(dcstream),int(n))
            self.assert_(
                len(dcstream) >= int(n),
                "Have not missed any discriminator crossings")
            dom.reset(True)
Esempio n. 2
0
    def testDiscriminatorEndurance(self):

        #Choosing an arbitrary DOM that we know exists in the detector configuration.
        omKey = icetray.OMKey(42, 2)
        geo = self.frame["I3Geometry"].omgeo
        cal = self.frame["I3Calibration"].dom_cal
        stat = self.frame["I3DetectorStatus"].dom_status

        dom = DOMLauncher.I3InIceDOM(self.random_service, omKey)
        dom.configure(cal[omKey], stat[omKey])

        for dt in np.linspace(30, 130, 100):
            for n in range(1, 120):
                pulses = simclasses.I3MCPulseSeries()
                pulse = simclasses.I3MCPulse()
                dcstream = DOMLauncher.DCStream()
                for n in range(0, int(n)):
                    pulse.charge = 3
                    pulse.time = n * dt
                    pulses.append(pulse)

                dom.discriminator(pulses, dcstream)
                self.assert_(
                    len(dcstream) >= int(n),
                    "Have not missed any discriminator crossings")
                dom.reset(True)
Esempio n. 3
0
    def testDiscriminatorThreshold(self):

        #Choosing an arbitrary DOM that we know exists in the detector configuration.
        omKey = icetray.OMKey(47, 2)
        geo = self.frame["I3Geometry"].omgeo
        cal = self.frame["I3Calibration"].dom_cal
        stat = self.frame["I3DetectorStatus"].dom_status

        dom = DOMLauncher.I3InIceDOM(self.random_service, omKey)
        dom.configure(cal[omKey], stat[omKey])

        #Creating a sub threshold pulse.
        pulses = simclasses.I3MCPulseSeries()
        pulse = simclasses.I3MCPulse()
        pulse.charge = 0.99 * dom.discriminator_threshold_fraction
        pulse.time = 100
        pulses.append(pulse)

        dcstream = DOMLauncher.DCStream()
        dom.discriminator(pulses, dcstream)

        self.assert_(
            len(dcstream) == 0, "No trigger if charge is less than threshold")

        #appending the pulse again so the total amplitude will be above the threshold.
        pulses.append(pulse)
        dom.discriminator(pulses, dcstream)

        self.assert_(
            len(dcstream) > 0, "Trigger if charge is greater than threshold")
Esempio n. 4
0
def dom_simulation(frame, time_shift=10, nhits=n_hits):
    global hit_times
    random_service = phys_services.I3GSLRandomService(2)
    geo = frame["I3Geometry"].omgeo
    cal = frame["I3Calibration"].dom_cal
    stat = frame["I3DetectorStatus"].dom_status
    #DOMLauncher.I3DOM.merge_pulses = True
    #DOMLauncher.I3DOM.use_tabulation(True)
    omKey1 = icetray.OMKey(47, 2)
    dom1 = DOMLauncher.I3InIceDOM(random_service, omKey1)
    dom1.configure(cal[omKey1], stat[omKey1])

    omKey2 = icetray.OMKey(47, 3)
    dom2 = DOMLauncher.I3InIceDOM(random_service, omKey2)
    dom2.configure(cal[omKey2], stat[omKey2])
    dom1.rapcal_time_shift = 0
    dom2.rapcal_time_shift = time_shift
    #making the doms neigbors
    dom2.get_neighbors().append(dom1)
    dom1.get_neighbors().append(dom2)

    pulses = simclasses.I3MCPulseSeries()
    pulse = simclasses.I3MCPulse()
    pulse.charge = 1
    pulse.time = 0
    for i in range(nhits):
        pulses.append(pulse)
        hit_times += [pulse.time]
        pulse.time += 29e3

    triggers = DOMLauncher.DCStream()
    print("simulating discriminator")
    dom1.discriminator(pulses, triggers)
    dom2.discriminator(pulses, triggers)

    triggers = sorted(triggers, key=lambda t: t.time)
    i = 0
    for trigg in triggers:
        if (i % 100 == 0):
            print(trigg.DOM, trigg.time)
        i += 1
        if (trigg.DOM == omKey1):
            dom1.add_trigger(trigg)
        elif (trigg.DOM == omKey2):
            dom2.add_trigger(trigg)
    print("ending simulation")
    dom1.trigger_launch(False)
    dom2.trigger_launch(False)
    launch_map = dataclasses.I3DOMLaunchSeriesMap()
    launch_map[dom1.get_omkey()] = dom1.get_domlaunches()
    launch_map[dom2.get_omkey()] = dom2.get_domlaunches()
    frame["InIceRawData"] = launch_map
Esempio n. 5
0
    def testDiscriminatorFindStressTest(self):

        #Choosing an arbitrary DOM that we know exists in the detector configuration.
        omKey = icetray.OMKey(42, 2)
        geo = self.frame["I3Geometry"].omgeo
        cal = self.frame["I3Calibration"].dom_cal
        stat = self.frame["I3DetectorStatus"].dom_status

        dom = DOMLauncher.I3InIceDOM(self.random_service, omKey)
        dom.configure(cal[omKey], stat[omKey])
        for n in range(0, 10):
            dcstream = DOMLauncher.DCStream()
            pulses = simclasses.I3MCPulseSeries()
            pulse = simclasses.I3MCPulse()
            last = 0
            seeds = list()
            for s in range(0, 5000):
                seed = last + np.random.uniform(10000, 12000)
                seeds.append(seed)
                last = seed
                pulse_times = np.random.normal(seed, 1.,
                                               10)  #np.random.poisson(10))

                pulse_times = sorted(pulse_times)
                for pulse_time in pulse_times:
                    pulse.charge = 2
                    pulse.time = pulse_time
                    #last = pulse.time
                    pulses.append(pulse)
            dom.discriminator(pulses, dcstream)
            notfound = 0

            #print(len(dcstream),int(5000))
            index = 0
            foundAll = True
            for seed in seeds:
                for i in range(index, len(dcstream)):
                    tr = dcstream[i]
                    index = i
                    if (np.abs(seed - tr.time) < 400):
                        break
                    elif ((tr.time - seed) > 400):
                        notfound += 1
                        foundAll = False
                        break
            self.assert_(foundAll,
                         "Missed %d discriminator crossings" % notfound)
Esempio n. 6
0
    def testSLC(self):
        random_service = phys_services.I3GSLRandomService(1337)
        key = OMKey(40, 40)
        cal = self.frame["I3Calibration"].dom_cal
        stat = self.frame["I3DetectorStatus"].dom_status

        for charge in range(1, 160):
            charge = charge / 2.
            for i in range(0, 30):
                dom = DOMLauncher.I3InIceDOM(random_service, key)
                dom.configure(cal[key], stat[key])
                pulses = simclasses.I3MCPulseSeries()
                pulse = simclasses.I3MCPulse()
                pulse.charge = charge
                pulse.time = 0
                pulses.append(pulse)

                dcstream = DOMLauncher.DCStream()
                dom.discriminator(pulses, dcstream)
                dcstream = sorted(dcstream, key=lambda t: t.time)
                for trigger in dcstream:
                    dom.add_trigger(trigger)
                dom.trigger_launch(True)
                launches = dom.get_domlaunches()

                for launch in launches:
                    self.assert_(launch.lc_bit == False,
                                 "All launches should be SLC")
                    global nLaunches
                    nLaunches += 1
                    stamp = launch.raw_charge_stamp
                    any_big = False
                    all_even = True
                    for sample in stamp:
                        if sample >= 512:
                            any_big = True
                        if sample % 2 == 1:
                            all_even = False
                    if (any_big):
                        global nBig
                        nBig += 1
                    if any_big and not all_even:
                        print("Bad SLC readout:", stamp)
                    self.assert_(
                        not any_big or (any_big and all_even),
                        "All samples must be small, or all must be even")
def testTiming(frame):
    global random_service

    #Choosing an arbitrary DOM that we know exists in the detector configuration.
    omKey = icetray.OMKey(42, 2)
    #geo = self.frame["I3Geometry"].omgeo
    cal = frame["I3Calibration"].dom_cal
    stat = frame["I3DetectorStatus"].dom_status

    dom = DOMLauncher.I3InIceDOM(random_service, omKey)
    dom.configure(cal[omKey], stat[omKey])

    import time
    #
    pulses = simclasses.I3MCPulseSeries()
    pulse = simclasses.I3MCPulse()
    print("Testing pulses densly distributed pulses")
    N = 2000
    for n in range(0, N):
        pulse.charge = 3
        pulse.time = n * 20
        pulses.append(pulse)

    tstream = DOMLauncher.DCStream()
    t1_st = time.clock()  #stopwatch.Timer()
    dom.discriminator(pulses, tstream)
    t1_end = time.clock()

    print("Discriminator1 elapsed time: %f, and found DCs: %d" %
          ((t1_end - t1_st), len(tstream)))

    print("Testing pulses far apart")
    pulses = simclasses.I3MCPulseSeries()
    pulse = simclasses.I3MCPulse()
    N = 2000
    for n in range(0, N):
        pulse.charge = 3
        pulse.time = n * 29000
        pulses.append(pulse)

    tstream = DOMLauncher.DCStream()
    t1_st = time.clock()  #stopwatch.Timer()
    dom.discriminator(pulses, tstream)
    t1_end = time.clock()

    print("Discriminator1 elapsed time: %f, and found DCs: %d" %
          ((t1_end - t1_st), len(tstream)))

    print("Testing random pulses pulse distribution")
    pulses = simclasses.I3MCPulseSeries()
    pulse = simclasses.I3MCPulse()
    last_t = 0
    N = 2000
    for n in range(0, N):
        pulse.charge = 3
        pulse.time = last_t + np.random.uniform(10, 29000)
        last_t = pulse.time
        pulses.append(pulse)

    tstream = DOMLauncher.DCStream()
    t1_st = time.clock()  #stopwatch.Timer()
    dom.discriminator(pulses, tstream)
    t1_end = time.clock()

    print("Discriminator1 elapsed time: %f, and found DCs: %d" %
          ((t1_end - t1_st), len(tstream)))
from os.path import expandvars
PATH = expandvars("$I3_TESTDATA/GCD")
GCDFN = PATH + "/GeoCalibDetectorStatus_IC86.55697_corrected_V2.i3.gz"

f = dataio.I3File(GCDFN)

fr = f.pop_frame()
while "I3Calibration" not in fr :
    fr = f.pop_frame()

domcal = fr["I3Calibration"].dom_cal


#Ploting residual of discriminator pulse template |interpolated-non_interpolated|
disc_pt = DOMLauncher.InterpolatedSPETemplate(domcal[icetray.OMKey(1,45)].discriminator_pulse_template(True))

times = np.arange(0,150000,0.1)

amps = np.array([disc_pt(t) for t in times])
st = 0
lin_chp = 80
quad_chp = 6400
disc_pt.tabulate(5000, 1000, st, lin_chp, quad_chp, 1e9)

amps_int = np.array([disc_pt(t) for t in times])

#pylab.axvspan(6400,1e9,facecolor='r', alpha=0.1)
print("Disc: Sum of absolute value of residuals: ",sum(abs(amps-amps_int)))

plt.loglog(times, abs(amps-amps_int))
Esempio n. 9
0
    def testSLC(self):
        geo = self.frame["I3Geometry"].omgeo
        cal = self.frame["I3Calibration"].dom_cal
        stat = self.frame["I3DetectorStatus"].dom_status

        omKey1 = icetray.OMKey(47, 2)
        dom1 = DOMLauncher.I3InIceDOM(self.random_service, omKey1)
        dom1.configure(cal[omKey1], stat[omKey1])

        omKey2 = icetray.OMKey(47, 3)
        dom2 = DOMLauncher.I3InIceDOM(self.random_service, omKey2)
        dom2.configure(cal[omKey2], stat[omKey2])

        #making the doms neigbors
        dom2.get_neighbors().append(dom1)
        dom1.get_neighbors().append(dom2)

        pulses1 = simclasses.I3MCPulseSeries()
        pulse = simclasses.I3MCPulse()
        pulse.charge = 1
        pulse.time = 0
        pulses1.append(pulse)

        pulses2 = simclasses.I3MCPulseSeries()
        pulse.time = 1025
        pulses2.append(pulse)

        dcstream = DOMLauncher.DCStream()

        dom1.discriminator(pulses1, dcstream)
        dom2.discriminator(pulses2, dcstream)

        dcstream = sorted(dcstream, key=lambda t: t.time)

        for trigg in dcstream:
            #print(trigg.DOM, trigg.time)
            if (trigg.DOM == omKey1):
                dom1.add_trigger(trigg)
            elif (trigg.DOM == omKey2):
                dom2.add_trigger(trigg)

        dom1.trigger_launch(True)
        dom2.trigger_launch(True)

        launches1 = dom1.get_domlaunches()
        launches2 = dom2.get_domlaunches()

        self.assert_(
            len(launches1) == 1, "First frame: DOM 1 produced one launch.")
        self.assert_(
            len(launches2) == 1, "First frame: DOM 2 produced one launch.")

        self.assert_(
            launches1[0].lc_bit == False and launches2[0].lc_bit == False,
            "First frame: Launches do not have LC.")

        # Simulating that we are going to the next frame and thus reset the DOMObjects.
        dom1.reset(True)
        dom2.reset(True)
        # Now we resimulate the same event and should get the same result back if the reset was
        # correct.
        dcstream = DOMLauncher.DCStream()
        dom1.discriminator(pulses1, dcstream)
        dom2.discriminator(pulses2, dcstream)

        dcstream = sorted(dcstream, key=lambda t: t.time)

        for trigg in dcstream:
            if (trigg.DOM == omKey1):
                dom1.add_trigger(trigg)
            elif (trigg.DOM == omKey2):
                dom2.add_trigger(trigg)

        dom1.trigger_launch(True)
        dom2.trigger_launch(True)

        launches1 = dom1.get_domlaunches()
        launches2 = dom2.get_domlaunches()

        self.assert_(
            len(launches1) == 1, "Second frame: DOM 1 produced one launch.")
        self.assert_(
            len(launches2) == 1, "Second frame: DOM 2 produced one launch.")

        self.assert_(
            launches1[0].lc_bit == False and launches2[0].lc_bit == False,
            "Second frame: Launches do not have LC.")

        # Simulating once more. This time we will not force the DOMs to launch at the
        # end of the frame.
        dom1.reset(True)
        dom2.reset(True)
        dcstream = DOMLauncher.DCStream()
        dom1.discriminator(pulses1, dcstream)
        dom2.discriminator(pulses2, dcstream)

        dcstream = sorted(dcstream, key=lambda t: t.time)

        for trigg in dcstream:
            if (trigg.DOM == omKey1):
                dom1.add_trigger(trigg)
            elif (trigg.DOM == omKey2):
                dom2.add_trigger(trigg)

        #Testing the option to not force launches at the end of the frame.
        #This option is used in Multi Frame Event mode.
        dom1.trigger_launch(False)
        dom2.trigger_launch(False)

        launches1 = dom1.get_domlaunches()
        launches2 = dom2.get_domlaunches()

        self.assert_(
            len(launches1) == 1, "Second frame: DOM 1 produced one launch.")
        self.assert_(
            len(launches2) == 0,
            "Second frame: DOM 2 did not produce a launch.")

        self.assert_(launches1[0].lc_bit == False,
                     "Third frame: Launch do not have LC.")
Esempio n. 10
0
    def testHLC(self):

        geo = self.frame["I3Geometry"].omgeo
        cal = self.frame["I3Calibration"].dom_cal
        stat = self.frame["I3DetectorStatus"].dom_status

        omKey1 = icetray.OMKey(47, 2)
        dom1 = DOMLauncher.I3InIceDOM(self.random_service, omKey1)
        dom1.configure(cal[omKey1], stat[omKey1])

        omKey2 = icetray.OMKey(47, 3)
        dom2 = DOMLauncher.I3InIceDOM(self.random_service, omKey2)
        dom2.configure(cal[omKey2], stat[omKey2])

        #making the doms neigbors
        dom2.get_neighbors().append(dom1)
        dom1.get_neighbors().append(dom2)

        pulses1 = simclasses.I3MCPulseSeries()
        pulse = simclasses.I3MCPulse()
        pulse.charge = 1
        pulse.time = 100
        pulses1.append(pulse)
        pulse.time = 6800
        pulses1.append(pulse)
        pulse.time = 7850
        pulses1.append(pulse)
        pulse.time = 8300
        pulses1.append(pulse)
        pulse.time = 8500
        pulses1.append(pulse)

        pulses2 = simclasses.I3MCPulseSeries()
        pulse.time = 500
        pulses2.append(pulse)

        dcstream = DOMLauncher.DCStream()

        dom1.discriminator(pulses1, dcstream)
        dom2.discriminator(pulses2, dcstream)

        dcstream = sorted(dcstream, key=lambda t: t.time)

        for trigg in dcstream:
            if (trigg.DOM == omKey1):
                dom1.add_trigger(trigg)
            elif (trigg.DOM == omKey2):
                dom2.add_trigger(trigg)

        dom1.trigger_launch(True)
        dom2.trigger_launch(True)

        launches1 = dom1.get_domlaunches()
        launches2 = dom2.get_domlaunches()

        self.assert_(len(launches1) > 0, "DOM 1 produced launch.")
        self.assert_(len(launches2) > 0, "DOM 2 produced launch.")

        self.assert_(
            launches1[0].lc_bit == True and launches2[0].lc_bit == True,
            "First pair of launches have LC.")
        for launch in launches1:
            self.assert_(launch.time < 7000,
                         "No launch during launch decision deadtime.")