def DoUnitTestEarthEvent(tray, name, options): #---------------- tray --------------- # run the module an tell me about what you find tray.AddService("I3SPRNGRandomServiceFactory", "Random", NStreams=2, Seed=options.Seed, StreamNum=1, InstallServiceAs="Random") tray.AddModule( "I3WimpSimReader", "wimpsim-reader", RandomServiceName="Random", FileNameList=[options.Infile], #default [""] NEvents=0, #default 0 StartMJD=56000., #default NAN EndMJD=(56000.), #default NAN Oversampling=0, #default 0 PositionLimits=[-800, 800, -800, 800, -800, 800], #default [-800,800,-800,800,-800,800] InjectionRadius=700 * I3Units.meter, #default 0 LowerZenCut=0 * I3Units.degree, #default 0*I3Units.degree, UpperZenCut=180 * I3Units.degree, #default 180*I3Units.degree SensitiveHeight=1300 * I3Units.meter, #default 0*I3Units.meter SensitiveRadius=700 * I3Units.meter, #default 0*I3Units.meter UseElectrons=True, #default False UseMuons=True, #default True UseTaus=True, #default False UseNC=True, #default False ) def Qframecounter(frame): global n_Qframes frame.Put("n_Qframes", icetray.I3Int(n_Qframes)) n_Qframes += 1 tray.AddModule(Qframecounter, "Qframecounter", Streams=[icetray.I3Frame.Stream('Q')]) if (options.RunTest): tray.AddModule(icetray.I3TestModuleFactory(TestEarthEventContent), "TestEarthEventContent", Streams=[icetray.I3Frame.DAQ]) tray.AddModule("Delete", "delete", keys=["n_Qframes"])
def check(fname='foo.i3', fraction=0.1): from unittest import TestCase tray = I3Tray() tray.AddModule('I3Reader', 'reader', filenamelist=[gcd, fname]) # set up a random number generator randomService = phys_services.I3SPRNGRandomService(seed=2, nstreams=10000, streamnum=1) # Throw out a random subset of events. The remainder must be reproducible # given the same random number sequence def drop_random_events(frame, fraction=fraction): return randomService.uniform(0, 1) < (1 - fraction) tray.AddModule(drop_random_events, 'triggerhappy', Streams=[icetray.I3Frame.DAQ]) tray.Add("Rename", keys=["MMCTrackList", "OldMMCTrackList"]) tray.AddModule('I3PropagatorModule', 'propagator', PropagatorServices=make_propagators(), RandomService=randomService, RNGStateName="RNGState", InputMCTreeName="RemadeMCTree", OutputMCTreeName="RemadeMCTree") class MCTreeCompare(TestCase): """ Ensure that every entry in the re-simulated MCTree is completely identical to the original one. """ def setUp(self): self.orig_tree = self.frame['I3MCTree'] self.orig_mmctracks = self.frame['OldMMCTrackList'] self.new_tree = self.frame['RemadeMCTree'] self.new_mmctracks = self.frame['MMCTrackList'] def testTotalSize(self): self.assertEquals(len(self.orig_tree), len(self.new_tree)) self.assertEquals(len(self.orig_mmctracks), len(self.new_mmctracks)) def testParticleContent(self): for p1, p2 in zip(self.orig_tree, self.new_tree): if p1.location_type != p1.InIce: continue self.assertEquals(p1.energy, p2.energy) self.assertEquals(p1.type, p2.type) self.assertEquals(p1.time, p2.time) self.assertEquals(p1.length, p2.length) for d in 'x', 'y', 'z': self.assertEquals(getattr(p1.pos, d), getattr(p2.pos, d)) for d in 'zenith', 'azimuth': self.assertEquals(getattr(p1.dir, d), getattr(p2.dir, d)) for t1, t2 in zip(self.orig_mmctracks, self.new_mmctracks): for prop in 'E', 'X', 'Y', 'Z', 'T': for location in 'i', 'c', 'f': method = 'Get' + prop + location self.assertEquals( getattr(t1, method)(), getattr(t2, method)()) tray.AddModule(icetray.I3TestModuleFactory(MCTreeCompare), 'testy', Streams=[icetray.I3Frame.DAQ]) tray.Execute()
n_slclaunches = 0 for launches in slcmap.values(): n_slclaunches += len(launches) self.assertEqual( n_slclaunches, 3, "I get wrong number of SLC = %d, expected is 3" % n_slclaunches) tray = I3Tray.I3Tray() tray.AddModule("BottomlessSource", 'BottomlessSource', stream=icetray.I3Frame.DAQ) tray.Add(Create_LaunchesSeriesMap, "Create_LaunchesSeriesMap", Streams=[icetray.I3Frame.DAQ]) from icecube import DomTools tray.AddModule('I3LCCleaning', 'I3LCCleaning', InIceInput="TestLauncheSeriesMap", InIceOutput="TestLauncheSeriesMapCleaning", InIceOutputSLC="TestLauncheSeriesMapCleaningSLC") tray.AddModule(icetray.I3TestModuleFactory(I3LCCleaningTest), 'testmodule', Streams=[icetray.I3Frame.DAQ]) tray.Execute(100)
self.assertEqual( hit_numbers[3].charge, 8, "4th surviving hit after IsolatedHitsCutModule should have been #8" ) self.assertEqual( hit_numbers[4].charge, 9, "5th surviving hit after IsolatedHitsCutModule should have been #9" ) self.assertEqual( hit_numbers[5].charge, 10, "6th surviving hit after IsolatedHitsCutModule should have been #10" ) self.assertEqual( hit_numbers[6].charge, 11, "7th surviving hit after IsolatedHitsCutModule should have been #11" ) tray = I3Tray() tray.Add("BottomlessSource") tray.Add(setup) tray.Add("I3IsolatedHitsCutModule<I3RecoPulse>", InputResponse="test_pulses", OutputResponse="cleaned_pulses", RTRadius=100 * I3Units.m, RTTime=500 * I3Units.ns, RTMultiplicity=2) tray.Add(icetray.I3TestModuleFactory(I3IsolatedHitsCutModuleTest)) tray.Execute(100) tray.Finish()
simcharge = sum([p.charge for p in \ self.frame[self.fakePulseKey][om]]) recocharge = sum([p.charge for p in \ self.frame[self.pulseKey][om]]) if simcharge == 0: basecharge = recocharge else: basecharge = simcharge if basecharge == 0: continue margin = 0.50 frac = math.fabs((simcharge - recocharge) / basecharge) fracdiffs.append(frac) self.assert_(frac < margin, \ ("Sim charge (%f) and reco charge (%f) match to " + "within %d%% (OM %s)") % (simcharge, recocharge, \ margin*100, om)) self.assert_(sum(fracdiffs)/len(fracdiffs) < 0.03, \ "Simulation and reco charges within 3% on average") tray.AddModule(icetray.I3TestModuleFactory(QTotCheck), 'testy', Streams=[icetray.I3Frame.DAQ]) tray.AddModule('TrashCan', 'can') tray.Execute() tray.Finish()
def RecreateMCTree(tray, name, MCTree="I3MCTree", RawMCTree="I3MCTreeRaw", RNGState="RNGState", Propagators=None, Paranoia=True): """ Recreate the results of lepton propagation and shower simulation that were discarded in order to save space. :param RawMCTree: name of the un-propagated I3MCTree to use as input :param MCTree: name of the re-propagated I3MCTree to put back in the frame :param RNGState: name of the object storing the state of the random number generator :param Propagators: an I3ParticleTypePropagatorServiceMap giving the propagators to use for each kind of particle. If this is None, use PROPOSAL for muons and CMC for showers. :param Paranoia: if True, compare the re-propagated result to the original when it is present in the frame and raise an assertion if they differ. """ from icecube import phys_services, sim_services if Propagators is None: Propagators = get_propagators() # NB: the parameters given here do not matter. If they are different # from the stored state the generator will be re-initialized. randomService = phys_services.I3SPRNGRandomService(seed=2, nstreams=10000, streamnum=1) recreate = lambda frame: RNGState in frame and MCTree not in frame audit = lambda frame: RNGState in frame and MCTree in frame tray.AddModule('I3PropagatorModule', name + 'Propagator', PropagatorServices=Propagators, RandomService=randomService, RNGStateName=RNGState, InputMCTreeName=RawMCTree, OutputMCTreeName=MCTree, If=recreate) if Paranoia: # Paranoid mode: check results ParanoidMCTree = name + "MCTree" tray.AddModule('I3PropagatorModule', name + 'ParanoidPropagator', PropagatorServices=Propagators, RandomService=randomService, RNGStateName=RNGState, InputMCTreeName=RawMCTree, OutputMCTreeName=ParanoidMCTree, If=audit) from unittest import TestCase from unittest.util import safe_repr def assertClose(self, a, b, rtol=1e-8, atol=0, msg=None): """ a and b are equal to within tolerances :param rtol: relative tolerance :param atol: absolute tolerance """ if abs(a - b) > atol + rtol * abs(b): if (atol > 0 and abs(a - b) > atol): standardMsg = "%s != %s to within %s (absolute)" % ( safe_repr(a), safe_repr(b), safe_repr(atol)) else: standardMsg = "%s != %s to within %s (relative)" % ( safe_repr(a), safe_repr(b), safe_repr(rtol)) msg = self._formatMessage(msg, standardMsg) raise self.failureException(msg) else: return TestCase.assertClose = assertClose class MCTreeAudit(TestCase): """ Ensure that every entry in the re-simulated MCTree is identical to the original one to within round-off error. """ def setUp(self): self.orig_tree = self.frame[MCTree] self.new_tree = self.frame[ParanoidMCTree] def testTotalSize(self): self.assertEquals(len(self.orig_tree), len(self.new_tree)) def testParticleContent(self): for p1, p2 in zip(self.orig_tree, self.new_tree): if p1.location_type != p1.InIce: continue self.assertEquals(p1.type, p2.type) self.assertClose(p1.energy, p2.energy, atol=1e-6, rtol=1e-9) self.assertClose(p1.time, p2.time, atol=1, rtol=1e-9) self.assertClose(p1.length, p2.length, atol=1e-6, rtol=1e-9) for d in 'x', 'y', 'z': self.assertClose(getattr(p1.pos, d), getattr(p2.pos, d), atol=1e-6, rtol=1e-9) for d in 'zenith', 'azimuth': self.assertClose(getattr(p1.dir, d), getattr(p2.dir, d), atol=1e-6, rtol=1e-9) tray.AddModule(icetray.I3TestModuleFactory(MCTreeAudit), name + 'ParanoidCheck', Streams=[icetray.I3Frame.DAQ], If=audit) tray.AddModule('Delete', name + 'DeleteParanoidCruft', Keys=[ParanoidMCTree], If=audit)
def DoUnitTestEarth(tray, name, options): #---------------- tray --------------- # run the module an tell me about what you find from icecube import icetray, dataclasses, dataio tray.AddService("I3SPRNGRandomServiceFactory", "Random", NStreams=2, Seed=options.Seed, StreamNum=1, InstallServiceAs="Random") tray.AddModule( "I3WimpSimReader", "wimpsim-reader", RandomServiceName="Random", FileNameList=[options.Infile], #default [""] NEvents=0, #default 0 StartMJD=55694, #default NAN EndMJD=(55694 + 365.25), #default NAN Oversampling=0, #default 0 PositionLimits=[-800, 800, -800, 800, -800, 800], #default [-800,800,-800,800,-800,800] InjectionRadius=700 * I3Units.meter, #default 0 LowerZenCut=0 * I3Units.degree, #default 0*I3Units.degree, UpperZenCut=180 * I3Units.degree, #default 180*I3Units.degree SensitiveHeight=1300 * I3Units.meter, #default 0*I3Units.meter SensitiveRadius=700 * I3Units.meter, #default 0*I3Units.meter UseElectrons=True, #default False UseMuons=True, #default True UseTaus=True, #default False UseNC=True, #default False ) def Wframecounter(frame): global n_Wframes frame.Put("n_Wframes", icetray.I3Int(n_Wframes)) n_Wframes += 1 tray.AddModule(Wframecounter, "Wframecounter", Streams=[icetray.I3Frame.Stream('W')]) if (options.RunTest): tray.AddModule(icetray.I3TestModuleFactory(TestIFrameContent), "TestIFrameContent", Streams=[icetray.I3Frame.Stream('W')], If=lambda frame: frame["n_Wframes"].value == 0 ) #this will not work, have to Hack tray.AddModule(icetray.I3TestModuleFactory(TestQFrameContent), "TestQFrameContent", Streams=[icetray.I3Frame.DAQ]) tray.AddModule(icetray.I3TestModuleFactory(TestWFrameContent), "TestWFrameContent", Streams=[icetray.I3Frame.Stream('W')], If=lambda frame: frame["n_Wframes"].value == 1 ) #this will not work, have to Hack tray.AddModule("Delete", "delete", keys=["n_Wframes"])
class FrameSplitter(icetray.I3Module, phys_services.I3Splitter): def __init__(self, context): icetray.I3Module.__init__(self, context) phys_services.I3Splitter.__init__(self, self.configuration) self.AddOutBox('OutBox') def Configure(self): pass def DAQ(self, frame): print('DAQ Frame') self.PushFrame(frame) for i in range(0, max_phys_frames): subframe = self.get_next_sub_event(frame) subframe['TriggerID'] = icetray.I3Int(i) self.PushFrame(subframe) return True # tray = I3Tray.I3Tray() tray.AddModule('I3Reader', 'reader', filename=fname) tray.AddModule(FrameSplitter, 'splitter') tray.AddModule(icetray.I3TestModuleFactory(DAQFrameSplitting), 'testy') tray.Execute() if os.path.exists(fname): os.unlink(fname)
EndMJD=(55694 + 365.25), #default NAN Oversampling=0, #default 0 PositionLimits=[-800, 800, -800, 800, -800, 800], #default [-800,800,-800,800,-800,800] InjectionRadius=700 * I3Units.meter, #default 0 LowerZenCut=0. * I3Units.degree, #default 0*I3Units.degree, UpperZenCut=180. * I3Units.degree, #default 180*I3Units.degree SensitiveHeight=1300. * I3Units.meter, #default 0*I3Units.meter SensitiveRadius=700. * I3Units.meter, #default 0*I3Units.meter UseElectrons=True, #default False UseMuons=True, #default True UseTaus=True, #default False UseNC=True, #default False ) tray.AddModule(icetray.I3TestModuleFactory(SunPosition), "TestIFrameContent", Streams=[icetray.I3Frame.DAQ]) if params.I3File: tray.AddModule( "I3Writer", "writer", #streams = [icetray.I3Frame.DAQ,icetray.I3Frame.Physics], filename=params.Outfile, ) tray.AddModule("TrashCan", "trashcan") if (params.NEvents == 0): tray.Execute()
rpsmap[omkey] = rps frame[self.output_map_name] = rpsmap self.PushFrame(frame) tray = I3Tray() tray.Add("BottomlessSource") tray.Add(SourceModule, OutputMapName="NoCleaningTest", HitTiming=[0, 400, -400, 0]) tray.Add("I3TimeWindowCleaning<I3RecoPulse>", InputResponse="NoCleaningTest", OutputResponse="NoCleaningTestCleaned", TimeWindow=1000.) # Units? tray.Add(SourceModule, OutputMapName="EarlyHitTest", HitTiming=[-1200, 0, 0, 0]) tray.Add("I3TimeWindowCleaning<I3RecoPulse>", InputResponse="EarlyHitTest", OutputResponse="EarlyHitTestCleaned", TimeWindow=1000.) # Units? tray.Add(SourceModule, OutputMapName="LateHitTest", HitTiming=[1200, 0, 0, 0]) tray.Add("I3TimeWindowCleaning<I3RecoPulse>", InputResponse="LateHitTest", OutputResponse="LateHitTestCleaned", TimeWindow=1000.) # Units? tray.Add(icetray.I3TestModuleFactory(I3TimeWindowFilterTest)) tray.Execute(100) tray.Finish()
for om in self.frame[self.fakePulseKey].keys(): if len(self.frame[self.fakePulseKey][om]) == 0: continue simfirst = self.frame[self.fakePulseKey][om][0].time for pulse in self.frame[self.pulseKey][om]: recofirst = pulse.time recowidth = pulse.width # Get a for-sure real pulse if pulse.charge > 0.6: break margin = 10 # sigma -- this is a crappy test, so it's # big (better test below) frac = math.fabs((recofirst - simfirst) / recowidth) fracdiffs.append(frac) self.assert_(frac < margin, \ ("Sim time (%f) and reco time (%f) match to " + "within %d sigma (%f ns) in OM %s") % (simfirst, \ recofirst, margin, margin*recowidth, om)) self.assert_(sum(fracdiffs)/len(fracdiffs) < 1, \ "Simulation and reco times within 1 sigma on average") tray.AddModule(icetray.I3TestModuleFactory(TimeCheck), 'testy', Streams=[icetray.I3Frame.DAQ]) tray.AddModule('TrashCan', 'can') tray.Execute() tray.Finish()
class I3ConcifyTest(unittest.TestCase): def test_I3ConcifyModule(self): pulsesmap1= self.frame['TestConcifyRecoPulseSeriesMap'] for pulses in pulsesmap1.values(): for p in pulses: self.failIfEqual(p.time,802., "There is a pulse with time = %d that exceeds the window of 800ns respect to its neighbors" %p.time) tray = I3Tray.I3Tray() icetray.set_log_level(icetray.I3LogLevel.LOG_DEBUG) tray.AddModule("BottomlessSource",'BottomlessSource') tray.Add(Create_PulseSeriesMap,"Create_PulseSeriesMap") from icecube import DomTools tray.AddModule('I3Coincify<I3RecoPulse>','I3Coincify', InputName="TestRecoPulseSeriesMap", OutputName="TestConcifyRecoPulseSeriesMap", IsolatedResponseName="IsolatedResponse", CoincidenceWindow=800.0*icetray.I3Units.ns)#default tray.AddModule(icetray.I3TestModuleFactory(I3ConcifyTest),'testmodule') tray.Execute(10)
# pulses. Note that this is not important, nor guaranteed, but tends # to break if the algorithm is broken for other reasons. def testNPulsesSane(self): fracdiffs = [] for om in self.frame[self.fakePulseKey].keys(): nsim = len(self.frame[self.fakePulseKey][om]) nreco = len(self.frame[self.pulseKey][om]) denom = nreco if denom == 0: denom = nsim if denom == 0: frac = 0 else: frac = math.fabs((float(nreco) - nsim)/denom) margin = 0.60 fracdiffs.append(frac) self.assert_(frac < margin, \ ("Sim npulses (%d) and reco (%d) match to " + "within %d%% in OM %s") % (nsim, \ nreco, margin*100, om)) print(sum(fracdiffs)/len(fracdiffs)) self.assert_(sum(fracdiffs)/len(fracdiffs) < 0.15, \ "Simulation and reco N pulses within 15% on average") tray.AddModule(icetray.I3TestModuleFactory(NPulsesCheck), 'testy', Streams=[icetray.I3Frame.DAQ]) tray.AddModule('TrashCan','can') tray.Execute() tray.Finish()
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") tray.AddModule(icetray.I3TestModuleFactory(SLC_check), 'testy', Streams=[icetray.I3Frame.DAQ]) tray.Execute(3 + 1) print("nLaunches =", nLaunches) print("nBig =", nBig)
InputName="MaskedOfflinePulses", OutputName="HC" + "MaskedOfflinePulses" + redo_org, Multiplicity=1, MaxTimeResidualEarly=-float("inf"), MaxTimeResidualLate=float("inf"), HiveConfigurationBlock=IceHiveZ.DefaultCB_Clean(), Stream=icetray.I3Frame.Physics, If=lambda f: True) if (test): tray.AddModule(I3HiveCleaningVerifier, "CleaningVerifier", OriginalName="HCOfflinePulses" + "_org", RedoName="HCOfflinePulses" + "_redo") tray.AddModule(icetray.I3TestModuleFactory(TestEqual), "TestEqual", Streams=[icetray.I3Frame.DAQ]) if (not test): tray.AddModule(FrameDelivery, "deliver", NRequested=int(sys.argv[1])) tray.AddModule( "I3Writer", "Writer", Filename=os.path.join( os.path.expandvars("$I3_BUILD"), "IceHiveZ/resources/i3hivecleaning_testcase.i3.bz2"), Streams=[ icetray.I3Frame.Geometry, #icetray.I3Frame.Calibration,
Oversampling=0, #default 0 PositionLimits=[-800, 800, -800, 800, -800, 800], #default [-800,800,-800,800,-800,800] InjectionRadius=700 * I3Units.meter, #default 0 LowerZenCut=0 * I3Units.degree, #default 0*I3Units.degree, UpperZenCut=180 * I3Units.degree, #default 180*I3Units.degree SensitiveHeight=1300 * I3Units.meter, #default 0*I3Units.meter SensitiveRadius=700 * I3Units.meter, #default 0*I3Units.meter UseElectrons=True, #default False UseMuons=True, #default True UseTaus=True, #default False UseNC=True, #default False ) if (test): tray.AddModule(icetray.I3TestModuleFactory(TestSunEventContent), "TestSunEventContent", Streams=[icetray.I3Frame.DAQ]) else: tray.AddModule( "I3Writer", "Writer", Filename=os.path.join( os.path.expandvars("$I3_BUILD"), "wimpsim-reader/resources/wimp_sun_testcase.i3.bz2"), Streams=[ #icetray.I3Frame.Geometry, #icetray.I3Frame.Calibration, #icetray.I3Frame.DetectorStatus, icetray.I3Frame.DAQ, #icetray.I3Frame.Physics
] for key in omKeys: self.assert_(key in launchMap.keys(), "All DOMs launched at least once.") launches = launchMap[icetray.OMKey(47, 1)] self.assert_( len(launches) == 2 and launches[0].lc_bit == True, "First DOM correct") launches = launchMap[icetray.OMKey(47, 2)] self.assert_( len(launches) == 2 and launches[0].lc_bit == True, "Second DOM correct") launches = launchMap[icetray.OMKey(47, 15)] self.assert_( len(launches) == 2 and launches[0].lc_bit == False, "Third DOM correct") launches = launchMap[icetray.OMKey(47, 25)] self.assert_( len(launches) == 1 and launches[0].lc_bit == True, "Fourth DOM correct") n += 1 tray.AddModule(icetray.I3TestModuleFactory(SanityCheck), 'testy', Streams=[icetray.I3Frame.DAQ]) tray.AddModule('TrashCan', 'end') tray.Execute(3 + 2) tray.Finish()
tray.Add(clone, Streams=[icetray.I3Frame.DAQ]) tray.AddModule( 'I3Writer', 'writer', Streams=[icetray.I3Frame.DAQ, icetray.I3Frame.Physics], # DropOrphanStreams=[icetray.I3Frame.DAQ], filename=outfile) tray.Execute(100) # second round: read back and test tray = I3Tray() tray.AddModule('I3Reader', 'reader', filenamelist=[outfile]) tray.AddModule(icetray.I3TestModuleFactory(LinearTreeTest), 'testy', Streams=[icetray.I3Frame.DAQ]) tray.AddModule('Delete', 'kill_mctree', Keys=['I3MCTree']) outfile = 'i3linearizedmctree_compact.i3.bz2' tray.AddModule( 'I3Writer', 'writer', Streams=[icetray.I3Frame.DAQ, icetray.I3Frame.Physics], # DropOrphanStreams=[icetray.I3Frame.DAQ], filename=outfile) tray.Execute(100)
from icecube import CoincSuite tray.AddModule("AlignmentTester", "MutualAlignmentTester", SplitName = SplitName, HypoName = HypoName, HypoFitName = "HFit", RecoFitName = "Fit", CriticalAngle = 2*CriticalAngle, CriticalDistance = CriticalDistance, MutualCompare=True) tray.AddModule("AlignmentTester", "HypoAlignmentTester", SplitName = SplitName, HypoName = HypoName, HypoFitName = "HFit", RecoFitName = "Fit", CriticalAngle = CriticalAngle, CriticalDistance = CriticalDistance, MutualCompare=False) tray.AddModule(icetray.I3TestModuleFactory(TestDaqSequence), "TestDaqSequence", Streams=[icetray.I3Frame.DAQ]) tray.AddModule(icetray.I3TestModuleFactory(TestPhysicsSequence), "TestPhysicsSequence", Streams=[icetray.I3Frame.Physics]) tray.Execute()
launchmap[omkey] = launch_series launchmap[icetray.OMKey(0, 3)].append(dataclasses.I3DOMLaunch()) return launchmap def source(frame): frame["InIceRawData"] = make_launch_map() class I3DOMLaunchCleaningTest(unittest.TestCase): def test_I3DOMLaunchCleaning(self): print self.frame launchmap = self.frame["CleanInIceRawData"] self.assertEqual(len(launchmap), 3, "Got %d DOMs. Expected 3." % len(launchmap)) for omkey, launch_series in launchmap: self.assertEqual(len(launch_series), 1, "Got %s launches on DOM %s. Expected 1."\ % (len(launch_series), str(omkey))) tray = I3Tray() tray.Add("BottomlessSource", stream=icetray.I3Frame.DAQ) tray.Add(source) tray.Add("I3DOMLaunchCleaning", CleanedKeys=[icetray.OMKey(0, 2)], FirstLaunchCleaning=True) tray.Add(icetray.I3TestModuleFactory(I3DOMLaunchCleaningTest)) tray.Execute(100) tray.Finish()
print(" %s" % str(event_header.start_time)) print(" %s" % str(self.event_header.start_time)) self.assertNotEqual(time_difference, 0, "TimeRange is not working correctly.") self.event_header = event_header tray = I3Tray() tray.context["I3RandomService"] = phys_services.I3GSLRandomService(1618); gcd_file = expandvars("$I3_TESTDATA/sim/GeoCalibDetectorStatus_2013.56429_V1.i3.gz") tray.AddModule("I3InfiniteSource", prefix=gcd_file, stream=icetray.I3Frame.DAQ) tray.AddModule(frame_setup, Streams = [icetray.I3Frame.DAQ]) tray.AddModule("I3GlobalTriggerSim", I3DOMLaunchSeriesMapNames = ["InIceRawData"], FromTime = dataclasses.I3Time(53005), ToTime = dataclasses.I3Time(53006), FilterMode = False, RunID = 0) tray.AddModule(icetray.I3TestModuleFactory(TestGlobalTriggerSim), Streams = [icetray.I3Frame.DAQ]) tray.Execute(10000) tray.Finish()
dlsm = dataclasses.I3DOMLaunchSeriesMap() dlsm[icetray.OMKey(7, 42)] = dataclasses.I3DOMLaunchSeries() frame['InIceRawData'] = dlsm t = dataclasses.I3Time() t.set_utc_cal_date(1919, 1, 15, 0, 0, 0, 0) frame['DrivingTime'] = t header = dataclasses.I3EventHeader() header.run_id = 7 header.event_id = 42 header.sub_event_id = 0 header.start_time = t header.end_time = t + 10 * I3Units.microsecond frame['I3EventHeader'] = header f.push(frame) frame = icetray.I3Frame( icetray.I3Frame.Physics) # a mostly-empty Physics frame. frame['DrivingTime'] = t + 2 header.sub_event_id = 1 frame['I3EventHeader'] = header f.push(frame) f.close() # Check I3Reader. tray = I3Tray.I3Tray() tray.Add('I3Reader', filename=fname) tray.Add(icetray.I3TestModuleFactory(DAQFrameMuxing)) tray.Execute() if os.path.exists(fname): os.unlink(fname)
)][0] #get an I3RecoPulseSeries with one element, the first one in time self.assertEqual( firstpulse_inFirstKey.time, 5.1, "I get wrong value for pulses = %d, expected is 5.1" % firstpulse_inFirstKey.time) firstpulse_inSecondKey = pulsesmap[icetray.OMKey( 25, 13 )][0] #get an I3RecoPulseSeries with one element, the first one in time self.assertEqual( firstpulse_inSecondKey.time, 1.2, "I get wrong value for pulses = %d, expected is 5.1" % firstpulse_inSecondKey.time) tray = I3Tray.I3Tray() tray.Add("BottomlessSource") tray.Add(Create_PulseSeriesMap, "Create_PulseSeriesMap") from icecube import DomTools tray.AddModule('I3FirstPulsifier', 'I3FirstPulsifier', InputPulseSeriesMapName="TestRecoPulseSeriesMap", OutputPulseSeriesMapName="TestFirstRecoPulseSeriesMap") tray.AddModule(icetray.I3TestModuleFactory(I3FirstPulsifierTest), 'testmodule') tray.Execute(100)
cleanmap= self.frame[OUTMAPNAME] for omkey in OMITTEDKEYS: self.assertTrue(not cleanmap.has_key(omkey), 'The OMKey {0} should not be in {1}'.format(omkey,OUTMAPNAME)) self.assertTrue(self.frame.Has('BadOMSelection'), 'I do not have BadOMSelection') self.assertEquals(len(self.frame['BadOMSelection']),len(OMITTEDKEYS), 'length of BadOMSelection is {0}, but should be {1}'.format(len(self.frame['BadOMSelection']),len(OMITTEDKEYS))) tray = I3Tray.I3Tray() icetray.set_log_level(icetray.I3LogLevel.LOG_TRACE) tray.Add(Create_PulsesMapAndGeometry,"Create_LaunchesSeriesMap") from icecube import DomTools tray.AddModule('I3OMSelection<I3RecoPulseSeries>','omselection', InputResponse="TestPulseSeriesMap", OutputResponse=OUTMAPNAME, OmittedKeys=OMITTEDKEYS, OutputOMSelection='BadOMSelection')#this is the default name to put into the frame, #all the bad OMKey's are stored in a I3Vector<OMKey> tray.AddModule(icetray.I3TestModuleFactory(I3OMSelectionTest),'testmodule') tray.Execute(10)