Ejemplo n.º 1
0
    def DAQ(self, frame):
        # only inject it once
        if self.has_been_injected:
            self.PushFrame(frame)
            return
        self.has_been_injected = True

        geometry = dataclasses.I3Geometry()
        calibration = dataclasses.I3Calibration()
        detectorStatus = dataclasses.I3DetectorStatus()

        # fill the geometry map
        omgeomap = geometry.omgeo
        domcalmap = calibration.dom_cal
        domstatusmap = detectorStatus.dom_status

        for i, pos in enumerate(omPositions):
            shiftedPos = pos
            shiftedPos[0] += self.xCoord * I3Units.m
            shiftedPos[1] += self.yCoord * I3Units.m
            shiftedPos[2] += self.zCoord * I3Units.m

            omkey = omKeys[i]

            newomgeo = dataclasses.I3OMGeo()
            newomgeo.omtype = dataclasses.I3OMGeo.OMType.IceCube
            newomgeo.orientation = dataclasses.I3Orientation(
                dataclasses.I3Direction(0., 0., -1.))
            newomgeo.position = dataclasses.I3Position(shiftedPos[0],
                                                       shiftedPos[1],
                                                       shiftedPos[2])
            omgeomap[omkey] = newomgeo

            newdomcal = dataclasses.I3DOMCalibration()
            newdomcal.relative_dom_eff = 1.0
            domcalmap[omkey] = newdomcal

            newdomstatus = dataclasses.I3DOMStatus()
            newdomstatus.pmt_hv = 1345. * I3Units.V  # some arbitrary setting: >0 and not NaN
            domstatusmap[omkey] = newdomstatus

        # make GCD frames and fill them with objects
        Gframe = icetray.I3Frame(icetray.I3Frame.Geometry)
        Cframe = icetray.I3Frame(icetray.I3Frame.Calibration)
        Dframe = icetray.I3Frame(icetray.I3Frame.DetectorStatus)

        Gframe["I3Geometry"] = geometry
        Cframe["I3Calibration"] = calibration
        Dframe["I3DetectorStatus"] = detectorStatus

        # push the new GCD frames
        self.PushFrame(Gframe)
        self.PushFrame(Cframe)
        self.PushFrame(Dframe)

        # push the original Q-frame
        self.PushFrame(frame)
    def test_MeanSPECharge_equality(self):
        fit1 = dataclasses.LinearFit()
        fit2 = dataclasses.LinearFit()
        ds1 = dataclasses.I3DOMStatus()
        dc1 = dataclasses.I3DOMCalibration()
        ds2 = dataclasses.I3DOMStatus()
        dc2 = dataclasses.I3DOMCalibration()

        fit1.slope = 1.618
        fit2.slope = 1.618
        fit1.intercept = 1.20205
        fit2.intercept = 1.20205
        ds1.dac_fadc_ref = 0.1234
        ds2.dac_fadc_ref = 0.1234

        dc1.fadc_baseline_fit = fit1
        dc2.fadc_baseline_fit = fit2

        mspe1 = dataclasses.mean_spe_charge(ds1, dc1)
        mspe2 = dataclasses.mean_spe_charge(ds2, dc2)

        self.assertEqual(mspe1, mspe2, "these should be the same.")
    def test_FADCBaseline_equality(self):
        fit1 = dataclasses.LinearFit()
        fit2 = dataclasses.LinearFit()
        ds1 = dataclasses.I3DOMStatus()
        dc1 = dataclasses.I3DOMCalibration()
        ds2 = dataclasses.I3DOMStatus()
        dc2 = dataclasses.I3DOMCalibration()

        fit1.slope = 1.618
        fit2.slope = 1.618
        fit1.intercept = 1.20205
        fit2.intercept = 1.20205
        ds1.dac_fadc_ref = 0.1234
        ds2.dac_fadc_ref = 0.1234

        dc1.fadc_baseline_fit = fit1
        dc2.fadc_baseline_fit = fit2

        fadcb1 = dataclasses.fadc_baseline(ds1, dc1)
        fadcb2 = dataclasses.fadc_baseline(ds2, dc2)

        self.assertEqual(fadcb1, fadcb2, "these should be the same.")
Ejemplo n.º 4
0
    def test_PulseChargeShifting(self):
        frame = icetray.I3Frame()
        omkey = icetray.OMKey(1, 1)

        # create a calibration object
        calibration = dataclasses.I3Calibration()
        calibration.dom_cal[omkey] = dataclasses.I3DOMCalibration()
        calibration.dom_cal[omkey].mean_atwd_charge = 1.2
        calibration.dom_cal[omkey].mean_fadc_charge = 1.8
        frame["I3Calibration"] = calibration

        # create some pulses on our fake DOM
        pulse1 = dataclasses.I3RecoPulse()
        pulse1.flags = dataclasses.I3RecoPulse.PulseFlags.ATWD
        pulse1.time = 1. * I3Units.nanosecond
        pulse1.charge = 10.
        pulse1.width = 1.

        pulse2 = dataclasses.I3RecoPulse()
        pulse2.flags = dataclasses.I3RecoPulse.PulseFlags.FADC
        pulse2.time = 10. * I3Units.nanosecond
        pulse2.charge = 5.
        pulse2.width = 1.

        pulse_series = dataclasses.I3RecoPulseSeriesMap()
        pulse_series[omkey] = dataclasses.I3RecoPulseSeries()
        pulse_series[omkey].append(pulse1)
        pulse_series[omkey].append(pulse2)

        # add these pulses to our new frame
        frame["UnshiftedPulses"] = pulse_series

        # create a shifter object
        frame[
            "ShiftedPulses"] = dataclasses.I3RecoPulseSeriesMapApplySPECorrection(
                pulses_key="UnshiftedPulses", calibration_key="I3Calibration")

        # retrieve the shifted pulses
        shifted_pulses = dataclasses.I3RecoPulseSeriesMap.from_frame(
            frame, "ShiftedPulses")

        # make sure everything is as expected
        self.assertEqual(pulse_series[omkey][0].time,
                         shifted_pulses[omkey][0].time,
                         "these should be the same.")
        self.assertEqual(pulse_series[omkey][0].width,
                         shifted_pulses[omkey][0].width,
                         "these should be the same.")
        self.assertEqual(pulse_series[omkey][0].flags,
                         shifted_pulses[omkey][0].flags,
                         "these should be the same.")
        self.assertAlmostEqual(pulse_series[omkey][0].charge /
                               calibration.dom_cal[omkey].mean_atwd_charge,
                               shifted_pulses[omkey][0].charge,
                               places=4,
                               msg="these should be the same.")

        self.assertEqual(pulse_series[omkey][1].time,
                         shifted_pulses[omkey][1].time,
                         "these should be the same.")
        self.assertEqual(pulse_series[omkey][1].width,
                         shifted_pulses[omkey][1].width,
                         "these should be the same.")
        self.assertEqual(pulse_series[omkey][1].flags,
                         shifted_pulses[omkey][1].flags,
                         "these should be the same.")
        self.assertAlmostEqual(pulse_series[omkey][1].charge /
                               calibration.dom_cal[omkey].mean_fadc_charge,
                               shifted_pulses[omkey][1].charge,
                               places=4,
                               msg="these should be the same.")
print('c', dataclasses.I3Constants.c)

print('Testing I3Direction')
dir = dataclasses.I3Direction(1.0, 1.0, 1.0)
print("Directions!", dir.theta, dir.phi, dir.azimuth, dir.zenith)

dir2 = dataclasses.I3Direction(1.0, 0.0, 0.0)
print(dir2)

dir2.rotate_z(90 * icetray.I3Units.deg)
print(dir2)

# Testing DOMFunctions
print('Testing I3DOMFunctions')
ds = dataclasses.I3DOMStatus()
dc = dataclasses.I3DOMCalibration()

transittime = dataclasses.transit_time(ds, dc)

dc.mean_fadc_charge = 0.6
dc.mean_atwd_charge = 0.7

spe_charge_dist = dataclasses.SPEChargeDistribution()

spe_charge_dist.exp1_amp = 0.1
spe_charge_dist.exp1_width = 0.2
spe_charge_dist.exp2_amp = 0.1
spe_charge_dist.exp2_width = 0.2
spe_charge_dist.gaus_amp = 0.3
spe_charge_dist.gaus_mean = 0.4
spe_charge_dist.gaus_width = 0.5
    def test_I3DOMCalibration_string(self):
        dc1 = dataclasses.I3DOMCalibration()
        dc2 = dataclasses.I3DOMCalibration()

        self.assertEqual(dc1.__str__(), dc2.__str__(),
                         "these should be the same.")
 def test_I3DOMCalibration_equality_default_ctor(self):
     dc1 = dataclasses.I3DOMCalibration()
     dc2 = dataclasses.I3DOMCalibration()
     self.assertEqual(dc1, dc2, "these should be the same.")
Ejemplo n.º 8
0
for i, pos in enumerate(omPositions):
    shiftedPos = pos
    shiftedPos[0] += options.XPOS*I3Units.m
    shiftedPos[1] += options.YPOS*I3Units.m
    shiftedPos[2] += options.ZPOS*I3Units.m

    omkey = omKeys[i]

    newomgeo = dataclasses.I3OMGeo()
    newomgeo.omtype = dataclasses.I3OMGeo.OMType.IceCube
    newomgeo.orientation = dataclasses.I3Orientation(dataclasses.I3Direction(0.,0.,-1.))
    newomgeo.position = dataclasses.I3Position(shiftedPos[0], shiftedPos[1], shiftedPos[2])
    omgeomap[omkey] = newomgeo


    newdomcal = dataclasses.I3DOMCalibration()
    newdomcal.relative_dom_eff = 1.0
    domcalmap[omkey] = newdomcal


    newdomstatus = dataclasses.I3DOMStatus()
    newdomstatus.pmt_hv = 1345.*I3Units.V # some arbitrary setting: >0 and not NaN
    domstatusmap[omkey] = newdomstatus



Gframe = icetray.I3Frame(icetray.I3Frame.Geometry)
Cframe = icetray.I3Frame(icetray.I3Frame.Calibration)
Dframe = icetray.I3Frame(icetray.I3Frame.DetectorStatus)

Gframe["I3Geometry"] = geometry