def test_I3FilterResult_string(self):
        fr1 = dataclasses.I3FilterResult()
        fr2 = dataclasses.I3FilterResult()

        fr1.condition_passed = 1
        fr2.condition_passed = 1
        fr1.prescale_passed = 1
        fr2.prescale_passed = 1

        self.assertEqual(fr1.__str__(), fr2.__str__(),
                         "these should be the same.")
    def test_I3FilterResult_bool(self):
        fr1 = dataclasses.I3FilterResult()
        fr1.condition_passed = 0
        fr1.prescale_passed = 0
        self.assertFalse(bool(fr1), "this should be false.")

        fr1 = dataclasses.I3FilterResult()
        fr1.condition_passed = 1
        fr1.prescale_passed = 0
        self.assertFalse(bool(fr1), "this should be false.")

        fr1 = dataclasses.I3FilterResult()
        fr1.condition_passed = 0
        fr1.prescale_passed = 1
        self.assertFalse(bool(fr1), "this should be false.")

        fr1 = dataclasses.I3FilterResult()
        fr1.condition_passed = 1
        fr1.prescale_passed = 1

        self.assertTrue(bool(fr1), "this should be true.")
Ejemplo n.º 3
0
    def Physics(self, frame):
        ## A place to store ouputs
        mymask = dataclasses.I3FilterResultMap()
        ## Loop over all keys in FilterConfigs, look for bools, apply prescales and add entry to FilterMask
        for filter_name, filter_prescale in self.filtconfigs:
            myfiltobj = dataclasses.I3FilterResult()
            if frame.Has(filter_name):
                filt_decision = frame.Get(filter_name)
                # assign the bool value to condition_passed AND prescale_passed for the filt obj
                if filt_decision.value:
                    myfiltobj.condition_passed = True
                    # calc prescale
                    if filter_prescale == 0:  #Filter off by definition
                        myfiltobj.prescale_passed = False
                    if filter_prescale == 1:  #Filter on, no prescale
                        myfiltobj.prescale_passed = True
                    if filter_prescale > 1:
                        if (self.randserv.uniform(1.0) * filter_prescale <
                                1.0):
                            myfiltobj.prescale_passed = True
                        else:
                            myfiltobj.prescale_passed = False
                else:
                    myfiltobj.condition_passed = False
                    myfiltobj.prescale_passed = False

            else:
                ## filter bool not in frame, didn't pass or run:
                myfiltobj.condition_passed = False
                myfiltobj.prescale_passed = False

            # store the filt obj in the mask
            mymask[filter_name] = myfiltobj

        ## Wedge your new filter mask into the frame
        frame[self.maskname] = mymask
        ## Don't forget to push frames!
        self.PushFrame(frame)
Ejemplo n.º 4
0
#!/usr/bin/env python
from icecube import icetray, dataclasses
from icecube.icetray.I3Test import *

from I3Tray import I3Units

##
## Some examples/simple tests for FilterMasks
##

print("Testing I3FilterResults")
filter1 = dataclasses.I3FilterResult()
filter1.prescale_passed = True
filter1.condition_passed = True

filter2 = dataclasses.I3FilterResult()
filter2.prescale_passed = True
filter2.condition_passed = False

filter3 = dataclasses.I3FilterResult()
filter3.prescale_passed = False
filter3.condition_passed = False

results = dataclasses.I3FilterResultMap()

results["Filter1"] = filter1
results["Filter2"] = filter2
results["Filter3"] = filter3

print(results)