def setUp(self): self.frame = icetray.I3Frame(icetray.I3Frame.Physics) pulses = dataclasses.I3RecoPulseSeriesMap() key1 = icetray.OMKey(42, 7) vec = dataclasses.I3RecoPulseSeries() pulse = dataclasses.I3RecoPulse() pulse.time = 1.0 pulse.charge = 2.3 vec.append(pulse) pulse.time = 2.0 vec.append(pulse) pulse.time = 15.0 vec.append(pulse) pulses[key1] = vec key2 = icetray.OMKey(7, 7) vec = dataclasses.I3RecoPulseSeries() pulse.time = 1.0 pulse.charge = 2.3 vec.append(pulse) pulse.time = 2.0 vec.append(pulse) pulse.time = 15.0 vec.append(pulse) pulses[key2] = vec self.frame['Pulses'] = pulses mask1 = dataclasses.I3RecoPulseSeriesMapMask(self.frame, 'Pulses') mask1.set(key1, 1, False) self.frame['Mask1'] = mask1 mask2 = dataclasses.I3RecoPulseSeriesMapMask(self.frame, 'Pulses') mask2.set(key2, 1, False) self.frame['Mask2'] = mask2
def Process(self): if not self.geometry: self.geometry = True geometry = dc.I3Geometry() for string in self.strings: for dom in self.doms: omkey= icetray.OMKey(string,dom) geometry.omgeo[omkey] = dc.I3OMGeo() x=random.uniform(-500,500) y=random.uniform(-500,500) z=random.uniform(-300,300) geometry.omgeo[omkey].position = dc.I3Position(x,y,z) frame = icetray.I3Frame(icetray.I3Frame.Geometry); frame.Put('I3Geometry',geometry) self.PushFrame(frame) pulsesmap= dc.I3RecoPulseSeriesMap() for string in self.strings: for dom in self.doms: omkey= icetray.OMKey(string,dom) pulse= dc.I3RecoPulse() pulse.charge= random.uniform(0.3,6.)#pulses are not used in the algorithm of this module, #just put a single pulse with any value of the charge pulsesmap[omkey]= dc.I3RecoPulseSeries([pulse]) frame = icetray.I3Frame(icetray.I3Frame.Physics); frame.Put("TestPulseSeriesMap",pulsesmap) self.PushFrame(frame)
def summarize(frame): global hits1, hits2 pulses = frame['WavedeformPulses'] for hit in pulses[icetray.OMKey(47, 2)]: hits1 += [hit.time] for hit in pulses[icetray.OMKey(47, 3)]: hits2 += [hit.time]
def make_grid_dict(input_shape, geometry): """Put the Icecube Geometry in a cubic grid. For each DOM calculate the corresponding grid position. Rotates the x-y-plane in order to make icecube better fit into a grid. Arguments: input_shape : The shape of the grid (x,y,z) geometry : Geometry file containing the positions of the DOMs in the Detector Returns: grid: a dictionary mapping (string, om) => (grid_x, grid_y, grid_z), i.e. dom id to its index position in the cubic grid dom_list_ret: list of all (string, om), i.e. list of all dom ids in the geofile (sorted(dom_list_ret)==sorted(grid.keys())) """ dom_6_pos = geometry[icetray.OMKey(6, 1)].position dom_1_pos = geometry[icetray.OMKey(1, 1)].position theta = -np.arctan( (dom_6_pos.y - dom_1_pos.y) / (dom_6_pos.x - dom_1_pos.x)) c, s = np.cos(theta), np.sin(theta) rot_mat = np.matrix([[c, -s], [s, c]]) grid = dict() DOM_List = [ i for i in geometry.keys() if i.om < 61 # om > 60 are icetops and i.string not in range(79, 87) ] # exclude deep core strings xpos = [geometry[i].position.x for i in DOM_List] ypos = [geometry[i].position.y for i in DOM_List] zpos = [geometry[i].position.z for i in DOM_List] rotxy = [ np.squeeze(np.asarray(np.dot(rot_mat, xy))) for xy in zip(xpos, ypos) ] xpos, ypos = zip(*rotxy) xmin, xmax = np.min(xpos), np.max(xpos) delta_x = (xmax - xmin) / (input_shape[0] - 1) xmin, xmaz = xmin - delta_x / 2, xmax + delta_x / 2 ymin, ymax = np.min(ypos), np.max(ypos) delta_y = (ymax - ymin) / (input_shape[1] - 1) ymin, ymaz = ymin - delta_y / 2, ymax + delta_y / 2 zmin, zmax = np.min(zpos), np.max(zpos) delta_z = (zmax - zmin) / (input_shape[2] - 1) zmin, zmax = zmin - delta_z / 2, zmax + delta_z / 2 dom_list_ret = [] for i, odom in enumerate(DOM_List): dom_list_ret.append((odom.string, odom.om)) # for all x,y,z-positions the according grid position is calculated and stored. # the last items (i.e. xmax, ymax, zmax) are put in the last bin. i.e. grid["om with x=xmax"]=(input_shape[0]-1,...) grid[(odom.string, odom.om)] = ( min(int(math.floor((xpos[i] - xmin) / delta_x)), input_shape[0] - 1), min(int(math.floor((ypos[i] - ymin) / delta_y)), input_shape[1] - 1), input_shape[2] - 1 - min( int(math.floor((zpos[i] - zmin) / delta_z)), input_shape[2] - 1 ) # so that z coordinates count from bottom to top (righthanded coordinate system) ) return grid, dom_list_ret
def make_geometry(): geo = dataclasses.I3Geometry() for omkey in doms: geo.omgeo[omkey] = dataclasses.I3OMGeo() geo.omgeo[icetray.OMKey(1, 1)].position = dataclasses.I3Position(0, 0, 0) geo.omgeo[icetray.OMKey(1, 2)].position = dataclasses.I3Position(0, 0, 50) geo.omgeo[icetray.OMKey(1, 3)].position = dataclasses.I3Position(0, 0, 100) geo.omgeo[icetray.OMKey(1, 4)].position = dataclasses.I3Position(0, 0, 500) geo.omgeo[icetray.OMKey(2, 4)].position = dataclasses.I3Position(0, 50, 500) return geo
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 testCompoundLaunches(self): launchMap = self.frame[self.domLaunchMapName] omKeys = [icetray.OMKey(47,1),icetray.OMKey(47,2),icetray.OMKey(47,3)] for key in omKeys: self.assert_( key in launchMap.keys(), "All DOMs launched at least once.") launches = launchMap[icetray.OMKey(47,1)] #print(len(launches), launches[0].lc_bit) self.assert_(len(launches) == 1 and launches[0].lc_bit == True, "First DOM correct") launch1 = launches[0] launches = launchMap[icetray.OMKey(47,2)] self.assert_(len(launches) == 2 and abs(launches[1].time-launch1.time) > 1000, \ "Second DOM correct")
def fakeit(frame): header = dataclasses.I3EventHeader() frame['I3EventHeader'] = header pulsemap = dataclasses.I3RecoPulseSeriesMap() pulses = dataclasses.I3RecoPulseSeries() pulse = dataclasses.I3RecoPulse() pulses.append(pulse) pulsemap[icetray.OMKey(7,42)] = pulses pulsemap[icetray.OMKey(9,42)] = pulses frame['Pulses'] = pulsemap mask = dataclasses.I3RecoPulseSeriesMapMask(frame, 'Pulses') frame['PulseMask'] = mask
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 convert_omkey(key): try: string = int(key.split(',')[0]) om = int(key.split(',')[1]) omkey = icetray.OMKey(string, om) return omkey except ValueError: icetray.logging.log_warn("%s is not an OMKey" % str(key))
def test_I3FirstPulsifierModule(self): pulsesmap = self.frame['TestFirstRecoPulseSeriesMap'] firstpulse_inFirstKey = pulsesmap[icetray.OMKey( 10, 4 )][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)
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 Process(self): frame = icetray.I3Frame(icetray.I3Frame.DAQ) mcpes = simclasses.I3MCPESeries() for i in range(1000) : mcpes.append(simclasses.I3MCPE(1)) mcpemap = simclasses.I3MCPESeriesMap() mcpemap[icetray.OMKey(21,30)] = mcpes frame["I3MCPESeriesMap"] = mcpemap self.PushFrame(frame)
def Geometry(self, gframe): geometry = gframe['I3Geometry'] self.stringx = zeros(87) self.stringy = zeros(87) for i in range(1, 87): self.stringx[i] = geometry.omgeo[icetray.OMKey(i, 1)].position.x self.stringy[i] = geometry.omgeo[icetray.OMKey(i, 1)].position.y self.PushFrame(gframe) # Dictionary with all the relevant things self.dcstrings = range(79, 87) self.stringdict = {} self.vertexdict = {} self.vertexdict_end = {} self.anglesdict = {} for one_string in self.dcstrings: self.anglesdict[one_string] = self.azimuthAngles(one_string) self.stringsInRange(one_string)
def Physics(self, frame): count = 0 for i in frame['Pulses'].keys(): if count == 0: frame['Pulses'][icetray.OMKey(1, 1, 0)] = frame['Pulses'][i] else: continue count += 1 self.PushFrame(frame)
def Physics(self, frame): rpsmap = dataclasses.I3RecoPulseSeriesMap() doms = [icetray.OMKey(0, i) for i in range(4)] for omkey, time in zip(doms, self.times): rp = dataclasses.I3RecoPulse() rp.time = time rps = dataclasses.I3RecoPulseSeries() rps.append(rp) rpsmap[omkey] = rps frame[self.output_map_name] = rpsmap self.PushFrame(frame)
def Create_PulseSeriesMap(frame): pulsesmap = dc.I3RecoPulseSeriesMap() p1 = dc.I3RecoPulse() p1.charge = 2.3 p1.time = 5.1 p2 = dc.I3RecoPulse() p2.charge = 1.5 p2.time = 9.1 pulsesmap[icetray.OMKey(10, 4)] = dc.I3RecoPulseSeries([p1, p2]) p1 = dc.I3RecoPulse() p1.charge = 4.5 p1.time = 43.1 p2 = dc.I3RecoPulse() p2.charge = 0.9 p2.time = 1.2 pulsesmap[icetray.OMKey(25, 13)] = dc.I3RecoPulseSeries([p1, p2]) frame.Put("TestRecoPulseSeriesMap", pulsesmap)
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 preprocess_grid(geometry): # rotate IC into x-y-plane dom_6_pos = geometry[icetray.OMKey(6, 1)].position dom_1_pos = geometry[icetray.OMKey(1, 1)].position theta = -np.arctan( (dom_6_pos.y - dom_1_pos.y) / (dom_6_pos.x - dom_1_pos.x)) c, s = np.cos(theta), np.sin(theta) rot_mat = np.matrix([[c, -s], [s, c]]) # om > 60 are icetops om 79-87 are deepcore --> exclude DOM_List = sorted( [i for i in geometry.keys() if i.om < 61 and i.string not in range(79, 87)]) xpos = [geometry[i].position.x for i in DOM_List] ypos = [geometry[i].position.y for i in DOM_List] zpos = [geometry[i].position.z for i in DOM_List] rotxy = [np.squeeze(np.asarray(np.dot(rot_mat, xy))) for xy in zip(xpos, ypos)] xpos, ypos = zip(*rotxy) return xpos, ypos, zpos, DOM_List
def Geometry(self, frame): #self.omgeo = frame['I3Geometry'].omgeo self.omgeomap = frame["I3OMGeoMap"] self.PMTdirections = [] for k in self.omgeomap.keys(): if k.string > 86: if self.omgeomap[k].omtype == 130: for pmt in range(24): thismodule = icetray.OMKey(k.string, k.om, pmt) self.PMTdirections.append(self.omgeomap[thismodule].orientation.dir) break self.PushFrame(frame)
def Configure(self): ''' Give the filename, read and load the constants in this method.''' self.filename = self.GetParameter("Filename") if self.filename.endswith('.bz2'): json_fit_values = json.loads(bz2.BZ2File(self.filename).read()) else: f = open(self.filename) json_fit_values = json.load(f) self.fit_dict = dict() for key, data in json_fit_values.iteritems(): # we don't really use the validity date in offline anymore if key == 'valid_date': continue # if none of the data is valid it's OK to skip entries. if bool(data['JOINT_fit']['valid']) == False and \ bool(data['ATWD_fit']['valid']) == False and \ bool(data['FADC_fit']['valid']) == False : continue string = int(key.split(",")[0]) om = int(key.split(",")[1]) omkey = icetray.OMKey(string, om) # set atwd/fadc means to NaN, consistent with # the treatment in dataclasses, if they're invalid atwd_mean = float(data['ATWD_fit']['gaus_mean']) \ if bool(data['ATWD_fit']['valid']) == True \ else numpy.nan fadc_mean = float(data['FADC_fit']['gaus_mean']) \ if bool(data['FADC_fit']['valid']) == True \ else numpy.nan exp_amp = float(data['JOINT_fit']['exp_norm']) exp_width = float(data['JOINT_fit']['exp_scale']) gaus_amp = float(data['JOINT_fit']['gaus_norm']) gaus_mean = float(data['JOINT_fit']['gaus_mean']) gaus_width = float(data['JOINT_fit']['gaus_stddev']) self.fit_dict[omkey] = { 'atwd_mean': atwd_mean, 'fadc_mean': fadc_mean, 'exp_amp': exp_amp, 'exp_width': exp_width, 'gaus_amp': gaus_amp, 'gaus_mean': gaus_mean, 'gaus_width': gaus_width }
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 Process(self): """ deliver frames QP with only a bit of rudamentary information """ #make a Q-frame Qframe = icetray.I3Frame(icetray.I3Frame.DAQ) Qeh = dataclasses.I3EventHeader() Qeh.start_time = (dataclasses.I3Time(2011, 0)) Qeh.end_time = (dataclasses.I3Time(2011, 2)) Qeh.run_id = 1 Qeh.event_id = 1 Qframe.Put("I3EventHeader", Qeh) Qrecomap = dataclasses.I3RecoPulseSeriesMap() recopulse1 = dataclasses.I3RecoPulse() recopulse1.time = 0 recopulse1.charge = 1 recopulse2 = dataclasses.I3RecoPulse() recopulse2.time = 1 recopulse2.charge = 2 Qrecomap[icetray.OMKey(1,1)] = [recopulse1] Qrecomap[icetray.OMKey(2,2)] = [recopulse2] Qframe.Put(OrgPulses, Qrecomap) Qframe.Put(SplitName+"SplitCount", icetray.I3Int(1)) self.PushFrame(Qframe) #now make the first p-frame containing one I3RecoPulse P1frame = icetray.I3Frame(icetray.I3Frame.Physics) P1eh = dataclasses.I3EventHeader() P1eh.start_time = (dataclasses.I3Time(2011, 0)) P1eh.end_time = (dataclasses.I3Time(2011, 1)) P1eh.run_id = 1 P1eh.event_id = 1 P1eh.sub_event_stream = "split" P1eh.sub_event_id = 0 P1frame.Put("I3EventHeader", P1eh) P1recomap = dataclasses.I3RecoPulseSeriesMap() P1recomap[icetray.OMKey(1,1)] = [recopulse1] P1recomask = dataclasses.I3RecoPulseSeriesMapMask(Qframe, OrgPulses, Qrecomap) P1frame.Put(SplitPulses, P1recomask) self.PushFrame(P1frame) self.RequestSuspension()
def Geometry(self, frame): self.omgeo = frame['I3Geometry'].omgeo self.n_pmts = max((k.pmt for k in self.omgeo.keys())) + 1 self.PMTdirections = [] for k in self.omgeo.keys(): if k.string > 86: if self.omgeo[k].omtype == 130: for pmt in range(24): thismodule = icetray.OMKey(k.string, k.om, pmt) self.PMTdirections.append( self.omgeo[thismodule].orientation.dir) break self.PushFrame(frame)
def Create_PulseSeriesMap(frame): pulsesmap= dc.I3RecoPulseSeriesMap() p1=dc.I3RecoPulse() p1.charge=2.3 p1.time=1.0*icetray.I3Units.ns p1.width=.0*icetray.I3Units.ns p2=dc.I3RecoPulse() p2.charge=1.5 p2.time=2.*icetray.I3Units.ns p2.width=.0*icetray.I3Units.ns pulsesmap[icetray.OMKey(10,4)]= dc.I3RecoPulseSeries([p1,p2]) p1=dc.I3RecoPulse() p1.charge=4.5 p1.time=3.0*icetray.I3Units.ns p1.width=.0*icetray.I3Units.ns p2=dc.I3RecoPulse() p2.charge=0.9 p2.time=802.*icetray.I3Units.ns #will find two pulses (in OMKey(10,4)) that are not in the window of 800 ns p2.width=.0*icetray.I3Units.ns pulsesmap[icetray.OMKey(10,5)]= dc.I3RecoPulseSeries([p1,p2]) frame.Put("TestRecoPulseSeriesMap",pulsesmap)
def GetDeltaT(self): # calculate the delay between launch and pulse from the calibration self.OffsetsDT = {} # see https://wiki.icecube.wisc.edu/index.php/Transit_time for string in range(1,87): for om in range(1,61): omkey = icetray.OMKey(string, om, 0) self.OffsetsDT[omkey] = self.PulseTimeOffset # initialize with default value for omkey in self.OffsetsDT.keys(): try: fit = self.cal.dom_cal[omkey].transit_time pmtHV = self.det.dom_status[omkey].pmt_hv/icetray.I3Units.V except: continue if pmtHV > 0: transit_time = fit.slope/math.sqrt(pmtHV) + fit.intercept self.OffsetsDT[omkey] = transit_time
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 Physics(self, frame): pulse_map = dataclasses.I3RecoPulseSeriesMap() for string in range(1, n_strings + 1): for om in range(1, n_doms + 1): om_key = icetray.OMKey(string, om) n_hits = np.random.poisson(lam=self.lambda_poisson) times = (np.random.random(n_hits) * self.event_length).round(1) pulse_series = dataclasses.I3RecoPulseSeries() for time in sorted(times): pulse = dataclasses.I3RecoPulse() pulse.time = time pulse.charge = 1.0 pulse_series.append(pulse) pulse_map[om_key] = pulse_series frame["SLOPPOZELA_Pulses"] = pulse_map self.PushFrame(frame)