def make_launch_map():
    launchmap = dataclasses.I3DOMLaunchSeriesMap()
    for omkey in doms:
        launch_series = dataclasses.I3DOMLaunchSeries()
        launch_series.append(dataclasses.I3DOMLaunch())
        launchmap[omkey] = launch_series

    launchmap[icetray.OMKey(0, 3)].append(dataclasses.I3DOMLaunch())
    return launchmap
def Create_LaunchesSeriesMap(frame):
    launchesmap = dc.I3DOMLaunchSeriesMap()

    l1 = dc.I3DOMLaunch()
    l1.time = 5.1
    l1.lc_bit = True
    l2 = dc.I3DOMLaunch()
    l2.time = 34.7
    l2.lc_bit = False
    launchesmap[icetray.OMKey(10, 4)] = dc.I3DOMLaunchSeries([l1, l2])

    l1 = dc.I3DOMLaunch()
    l1.time = 6.0
    l1.lc_bit = False
    l2 = dc.I3DOMLaunch()
    l2.time = 11.3
    l2.lc_bit = False
    launchesmap[icetray.OMKey(25, 13)] = dc.I3DOMLaunchSeries([l1, l2])

    frame.Put("TestLauncheSeriesMap", launchesmap)
 def AppendLaunches(self, launchmap, hit):
   newLaunch = dataclasses.I3DOMLaunch()
   newLaunch.time = hit.Time
   newLaunch.lc_bit = True
   if hit.OMKey not in launchmap.keys():
       newLaunchSeries = dataclasses.I3DOMLaunchSeries()
       newLaunchSeries.append(newLaunch)
       launchmap[hit.OMKey] = newLaunchSeries
   else:
       for launch in  launchmap[hit.OMKey]:
           if launch.time == hit.Time: return
       launchmap[hit.OMKey].append(newLaunch)
def frame_setup(frame):
    frame["I3Triggers"] = dataclasses.I3TriggerHierarchy()

    dom_launch = dataclasses.I3DOMLaunch()
    dom_launch.time = 42*I3Units.ns

    dom_launch_series = dataclasses.I3DOMLaunchSeries()
    dom_launch_series.append(dom_launch)

    launch_map = dataclasses.I3DOMLaunchSeriesMap()
    launch_map[icetray.OMKey(21,30)] = dom_launch_series
                        
    frame["InIceRawData"] = launch_map
    def DAQ(self, frame):
        print("DAQ!!!")

        geo = frame.Get("I3Geometry")

        if self.domSetsName in frame:
            domSets = frame.Get(self.domSetsName)
        else:
            domSets = None  # InDOMSet() will use the default table if there is no frame object

        omlist_l = list()
        for omkey, omgeo in geo.omgeo:
            if omgeo.omtype == dataclasses.I3OMGeo.IceCube and \
                  ( ( self.generateInDOMSet and trigger_sim.InDOMSet(omkey,4,domSets) ) or \
                    ( not self.generateInDOMSet and not trigger_sim.InDOMSet(omkey,4,domSets) ) ):
                omlist_l.append(omkey)

        launchmap = dataclasses.I3DOMLaunchSeriesMap()
        launch_counter = 0
        for i in range(self.nDOMs):
            launch = dataclasses.I3DOMLaunch()
            launch.lc_bit = True

            # set start times according to uniform distribution
            time = random.uniform(0, self.timeWindow)
            if not self.generateInTimeWindow:
                time += launch_counter * self.timeWindow

            launch.time = time

            ## select from the available list
            omkey = random.sample(omlist_l, 1)[0]

            if not omkey in launchmap:
                launchmap[omkey] = dataclasses.I3DOMLaunchSeries()

            launchmap[omkey].append(launch)

            launch_counter += 1

        frame["InIceRawData"] = launchmap

        self.PushFrame(frame)
    def DAQ(self, frame):
        print("DAQ!!!")

        geo = frame.Get("I3Geometry")

        omlist_l = list()
        for omkey, omgeo in geo.omgeo:
            if omgeo.omtype == self.domType:
                omlist_l.append(omkey)

        launchmap = dataclasses.I3DOMLaunchSeriesMap()
        launch_counter = 0
        for i in range(self.nDOMs):
            launch = dataclasses.I3DOMLaunch()
            launch.lc_bit = True

            # set start times according to uniform distribution
            time = random.uniform(0, self.timeWindow)
            if not self.generateInTimeWindow:
                time += launch_counter * self.timeWindow

            launch.time = time

            ## select from the available list
            omkey = random.sample(omlist_l, 1)[0]

            if not omkey in launchmap:
                launchmap[omkey] = dataclasses.I3DOMLaunchSeries()

            launchmap[omkey].append(launch)

            launch_counter += 1

        if self.domType == dataclasses.I3OMGeo.IceCube:
            frame["InIceRawData"] = launchmap
        if self.domType == dataclasses.I3OMGeo.IceTop:
            frame["IceTopRawData"] = launchmap

        self.PushFrame(frame)
omg.position.z = 102.0
print(type(omg.position), omg.position)
i3g = dataclasses.I3Geometry()
i3g.omgeo[icetray.OMKey(1, 1)] = omg
ENSURE(icetray.OMKey(1, 1) in i3g.omgeo, 'can not find my omkey in i3geo')
ENSURE((icetray.OMKey(1, 2) not in i3g.omgeo), 'found a bad omkey in i3geo')
newom = i3g.omgeo[icetray.OMKey(1, 1)]
print(type(newom.position), vars(newom.position), newom.position)
ENSURE(newom.position.x > 99.0, 'Failed to get the right OMGeo position back')

# I3Calibratoim example? (olivas have one?)
## See the Fix_Cals_in_GCD.py script for full example

#I3DOMLaunch
print('Testing I3DOMLaunch')
dl = dataclasses.I3DOMLaunch()
fadc = icetray.vector_int()
for i in range(10):
    fadc.append(i)
dl.raw_fadc = fadc
print(fadc)

vc = dataclasses.I3VectorChar()
for c in "I am an I3Vector<char>":
    vc.append(c)
print(vc)

atwd0 = icetray.vector_int()
[atwd0.append(i) for i in range(100)]
dl.raw_atwd[0] = atwd0
dl.lc_bit = True
    def DAQ(self, frame):
        print("DAQ!!!")

        geo = frame.Get("I3Geometry")

        omlist_l = list()
        for omkey, omgeo in geo.omgeo:
            if omkey.GetString() == self.stringN:
                if omgeo.omtype == dataclasses.I3OMGeo.IceCube:
                    omlist_l.append(omkey)

        time = 100. * I3Units.ns

        if not self.trigTest:
            print("You are TESTING <<THE NON-EXISTENSE>> of a STRING TRIGGER")

            #Get non adjacent  (self.threshold) OMs along a string
            noms = [
                random.randrange(1, 58, 7) for x in range(self.threshold - 2)
            ]
            #make sure that they are not adjacent
            noms.extend([0, 59])

            #create a list of DOMLaunches which do fulfill a string trigger condition

            launchmap = dataclasses.I3DOMLaunchSeriesMap()

            for i in range(self.threshold):

                launch = dataclasses.I3DOMLaunch()
                launch.SetLCBit(True)

                time += i * 100 * I3Units.ns
                launch.SetStartTime(time)

                #choose randomly 5/3 oms from doms between 50 and 56 in string number 1
                omkey = omlist_l[noms[i]]
                print(omkey)

                if not omkey in launchmap:
                    launchmap[omkey] = dataclasses.I3DOMLaunchSeries()

                launchmap[omkey].append(launch)

            frame["InIceRawData"] = launchmap

        else:
            print("You are TESTING <<THE- EXISTENSE>> of a STRING TRIGGER")

            #create a list of DOMLaunches which "DO NOT" fulfill a string trigger condition
            launchmap = dataclasses.I3DOMLaunchSeriesMap()

            for i in range(self.threshold):

                launch = dataclasses.I3DOMLaunch()
                launch.SetLCBit(True)

                time += i * 100. * I3Units.ns
                launch.SetStartTime(time)

                #choose randomly 5 oms from doms between 30 and 37 in string number 1
                omkey = random.sample(omlist_l[30:36], 1)[0]

                if not omkey in launchmap:
                    launchmap[omkey] = dataclasses.I3DOMLaunchSeries()

                launchmap[omkey].append(launch)

            frame["InIceRawData"] = launchmap

        self.PushFrame(frame)
    def DAQ(self, frame):
        print("DAQ!!!")

        geo = frame.Get("I3Geometry")

        omlist_l = list()
        for omkey, omgeo in geo.omgeo:
            if omkey.GetString() == self.stringN:
                if omgeo.omtype == dataclasses.I3OMGeo.IceCube:
                    omlist_l.append(omkey)

        oms_l = list()
        noms = [random.randint(0, 59) for r in range(self.nDOMs)]
        noms.sort()
        ajcent = True
        while (ajcent):
            k = random.randint(0, len(noms) - 1)

            if (k + 7) < len(noms):

                if (noms[k + 7] - noms[k] <= 7 and noms[k + 7] - noms[k] >= 0):
                    for i in range(k, k + 7, 1):
                        oms_l.append(noms[i])
                    ajcent = False
                else:
                    continue

        noTimeCorr = True
        while (noTimeCorr):
            time_l = [
                random.random() * self.timeWindow * I3Units.ns
                for x in range(self.threshold)
            ]
            time_l.sort()
            if ((time_l[-1] - time_l[0]) <= self.timeWindow * I3Units.ns):
                noTimeCorr = False
            else:
                continue

        TriggerLengthExpectation = time_l[-1] - time_l[0]
        trigLength = dataclasses.I3Double(TriggerLengthExpectation *
                                          I3Units.ns)
        frame.Put(self.where, trigLength)

        time = 100. * I3Units.ns
        if self.trigTest:

            print("You are TESTING <<THE EXISTENSE>> of a STRING TRIGGER")

            #create a list of DOMLaunches which do fulfill a string trigger condition

            launchmap = dataclasses.I3DOMLaunchSeriesMap()

            for i in range(self.threshold):

                omkey = omlist_l[random.sample(oms_l, 1)[0]]

                # for the slow monopole case we had about 60 launches per OM

                launch = dataclasses.I3DOMLaunch()
                launch.SetLCBit(True)

                launch.SetStartTime(time_l[i])

                if not omkey in launchmap:
                    launchmap[omkey] = dataclasses.I3DOMLaunchSeries()

                launchmap[omkey].append(launch)

            frame["InIceRawData"] = launchmap

        else:
            print("You are TESTING <<NON-EXISTENSE>> of a STRING TRIGGER")

            #create a list of DOMLaunches which "DO NOT" fulfill a string trigger condition
            launchmap = dataclasses.I3DOMLaunchSeriesMap()

            for i in range(self.threshold):

                launch = dataclasses.I3DOMLaunch()
                launch.SetLCBit(True)

                time += i * 1000. * I3Units.ns
                launch.SetStartTime(time)

                #choose randomly 5 oms from doms between 30 and 37 in string number 1
                omkey = random.sample(omlist_l[50:56], 1)[0]

                if not omkey in launchmap:
                    launchmap[omkey] = dataclasses.I3DOMLaunchSeries()

                launchmap[omkey].append(launch)

            frame["InIceRawData"] = launchmap

        self.PushFrame(frame)
Exemple #10
0
def TestSetup(frame, add_empty_trigger=False, add_mchits=True):

    p = dataclasses.I3Particle()
    p.time = TIME

    frame["MCPrimary"] = p

    mctree = dataclasses.I3MCTree()
    mctree.add_primary(p)
    frame["MCTree"] = mctree

    # I3MMCTrack
    mmctrack = simclasses.I3MMCTrack()
    mmctrack.SetParticle(p)
    mmctrack.ti = TIME
    mmctrack.tc = TIME
    mmctrack.tf = TIME
    mmctracklist = simclasses.I3MMCTrackList()
    mmctracklist.append(mmctrack)
    frame["MMCTracks"] = mmctracklist

    # I3TriggerHierarchy
    t = dataclasses.I3Trigger()
    t.time = TIME
    t.fired = True
    trigger_h = dataclasses.I3TriggerHierarchy()
    if not add_empty_trigger:
        trigger_h.insert(t)
    frame["Trigger"] = trigger_h

    # I3VectorI3Trigger
    t1 = dataclasses.I3Trigger()
    t1.time = TIME
    t1.fired = True
    trigger_v = dataclasses.I3VectorI3Trigger()
    trigger_v.append(t1)
    frame["TriggerVector"] = trigger_v

    # I3FlasherInfoVector
    fi = dataclasses.I3FlasherInfo()
    fi.flash_time = TIME
    fi_v = dataclasses.I3FlasherInfoVect()
    fi_v.append(fi)
    frame["FlasherInfos"] = fi_v

    # I3DOMLaunchSeriesMap
    d = dataclasses.I3DOMLaunch()
    d.time = TIME
    launchseries = dataclasses.I3DOMLaunchSeries()
    launchseries.append(d)
    launchmap = dataclasses.I3DOMLaunchSeriesMap()
    launchmap[icetray.OMKey(21, 30)] = launchseries
    frame["DOMLaunchMap"] = launchmap

    # I3MCHit
    mchit = dataclasses.I3MCHit()
    mchit.time = TIME
    mchitseries = dataclasses.I3MCHitSeries()
    mchitseries.append(mchit)
    mchitmap = dataclasses.I3MCHitSeriesMap()
    mchitmap[icetray.OMKey(21, 30)] = mchitseries
    if add_mchits:
        frame["MCHitMap"] = mchitmap

    # I3MCPE
    mcpe = simclasses.I3MCPE()
    mcpe.time = TIME
    mcpeseries = simclasses.I3MCPESeries()
    mcpeseries.append(mcpe)
    mcpemap = simclasses.I3MCPESeriesMap()
    mcpemap[icetray.OMKey(21, 30)] = mcpeseries
    frame["MCPEMap"] = mcpemap

    # I3MCPulse
    mcpulse = simclasses.I3MCPulse()
    mcpulse.time = TIME
    mcpulseseries = simclasses.I3MCPulseSeries()
    mcpulseseries.append(mcpulse)
    mcpulsemap = simclasses.I3MCPulseSeriesMap()
    mcpulsemap[icetray.OMKey(21, 30)] = mcpulseseries
    frame["MCPulseMap"] = mcpulsemap

    # I3Double
    sometime = dataclasses.I3Double(TIME)
    frame["SomeTime"] = sometime
    nottime = dataclasses.I3Double(TIME)
    frame["NotTime"] = nottime