def generatePulses(frame): # this dom is the one which should launch while its only LC partner (dom 2) is # dead from previous launches dom1 = OMKey(47, 1) # this dom will be hit at all three times, first to ensure that both digitizers # are busy and then to supply the LC high to dom1 dom2 = OMKey(47, 2) # this dom will be pulse twice (time1 and time 2) to ensure that dom2 has LC and # makes HLC readouts (to maximize deadtime) dom3 = OMKey(47, 3) #This is a IT DOM to test IT SLC dom4 = OMKey(47, 62) pulseWeight = 1000 time1 = 0 time2 = time1 + 6600 time3 = time2 + 8000 pulses = simclasses.I3MCPulseSeriesMap() series1 = simclasses.I3MCPulseSeries() series2 = simclasses.I3MCPulseSeries() series3 = simclasses.I3MCPulseSeries() pulse = simclasses.I3MCPulse() pulse.charge = pulseWeight pulse.time = time1 series3.append(pulse) series2.append(pulse) pulse.time = time2 series3.append(pulse) series2.append(pulse) pulse.time = time3 series2.append(pulse) series1.append(pulse) pulses[dom1] = series1 pulses[dom2] = series2 pulses[dom3] = series3 pulse.charge = 5000 pulse.time = 500000 series2.append(pulse) pulses[dom4] = series2 frame.Put("TestPulses", pulses)
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)
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)
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")
def generatePulses(frame): global n dom1 = OMKey(47,1) dom2 = OMKey(47,2) dom3 = OMKey(47,15) dom4 = OMKey(47,25) dom5 = OMKey(47,26) pulseWeight = 10 pulses = simclasses.I3MCPulseSeriesMap() series = simclasses.I3MCPulseSeries() pulse = simclasses.I3MCPulse() pulse.charge = pulseWeight if(n==1): time1 = 0 time2 = 29*icetray.I3Units.microsecond else: time1 = 2*29*icetray.I3Units.microsecond time2 = 3*29*icetray.I3Units.microsecond series2 = simclasses.I3MCPulseSeries() series3 = simclasses.I3MCPulseSeries() pulse.time = time1 series.append(pulse) pulse.time = time2 series.append(pulse) pulses[dom1]=series pulses[dom2]=series pulses[dom3]=series if(n == 1): pulses[dom4]=series else: pulse.time = 29*icetray.I3Units.microsecond+200 series = simclasses.I3MCPulseSeries() series.append(pulse) pulses[dom5]=series frame.Put("TestPulses",pulses)
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
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)
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)))
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.")
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.")
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