def find_final_neutrino(frame, mctree_name): mcTree = frame[mctree_name] # print(mcTree) #try to figure out which neutrino is the primary primaryNeutrino = dataclasses.get_most_energetic_primary(mcTree) frame["PrimaryNeutrino"] = primaryNeutrino if (primaryNeutrino == None or not is_neutrino(primaryNeutrino.type)): return #walk down the tree to find the first daughter neutrino which is 'InIce' neutrino = primaryNeutrino while (neutrino.location_type != dataclasses.I3Particle.LocationType.InIce): children = mcTree.get_daughters(neutrino) foundNext = False #take the first child which is a neutrino; #for in-Earth NC interactions it should be the only one anyway for child in children: if (is_neutrino(child.type)): neutrino = child foundNext = True break if (not foundNext): print("did not find a daughter neutrino") return #bail out frame["InteractingNeutrino"] = neutrino stop_pos = neutrino.pos + neutrino.dir * neutrino.length frame["VertexPosition"] = stop_pos
def get_most_energetic_primary2(mctree): # temporary fix for get_most_energetic_primary, see bug 958 rval = get_most_energetic_primary(mctree) if not rval and mctree.primaries: highest_energy = 0.0 for x in mctree.primaries: if x.energy > highest_energy: highest_energy = x.energy rval = x return rval
def test_get_most_energetic_primary(self): primary1 = dc.I3Particle() primary1.energy = 10 * I3Units.TeV primary2 = dc.I3Particle() primary2.energy = 1 * I3Units.TeV tree = dc.I3MCTree() tree.insert(primary1) tree.insert(primary2) mep = get_most_energetic_primary(tree) self.assertTrue(mep, "got no particles, but there are primaries.") self.assertEqual(mep.id, primary1.id, "got the wrong particle.")
def testPrimary(self): primary = dataclasses.get_most_energetic_primary( self.frame['I3MCTree']) self.assert_(primary.type == dataclasses.I3Particle.PPlus, "Proton primary") self.assert_( abs(primary.dir.zenith - 0.1163) < 0.001, "Zenith matches") self.assert_( abs(primary.dir.azimuth - 1.94033) < 0.001, "Azimuth matches") self.assert_( abs(primary.energy - 71.147 * I3Units.TeV) < 1 * I3Units.GeV, "Energy matches") self.assert_( math.sqrt(primary.pos.x**2 + primary.pos.y**2 + primary.pos.z**2) < 1600, "Inside detector volume")
def testTree(self): primary = dataclasses.get_most_energetic_primary( self.frame['I3MCTree']) print('%d particles in tree' % len(self.frame['I3MCTree'])) self.assert_( len(self.frame['I3MCTree']) == 1350, "1350 particles in tree") allowed_particles = [ dataclasses.I3Particle.MuMinus, dataclasses.I3Particle.MuPlus, dataclasses.I3Particle.NuE, dataclasses.I3Particle.NuEBar, dataclasses.I3Particle.NuMu, dataclasses.I3Particle.NuMuBar, dataclasses.I3Particle.NuTau, dataclasses.I3Particle.NuTauBar, dataclasses.I3Particle.PPlus ] for particle in self.frame['I3MCTree']: self.assert_(particle.type in allowed_particles, "Particle type is one that should be in the MC Tree") self.assert_(particle.energy <= primary.energy, "Energy conservation")
def extractMCTreeParticles(frame): mctree = frame["I3MCTree"] # get tracks in ice/water mctracksinice = mctree.get_filter(lambda p: p.location_type == p.InIce) mcmuontrack = None highestEnergy = -1. for track in mctracksinice: if track.energy > highestEnergy: highestEnergy = track.energy mcmuontrack = track if mcmuontrack is None: mcmuontrack = dataclasses.I3Particle() primary = dataclasses.get_most_energetic_primary(mctree) if primary is None: primary = dataclasses.I3Particle() frame["MCMostEnergeticInIce"] = mcmuontrack frame["MCMostEnergeticPrimary"] = primary
def extractMCTreeParticles(frame): mctree = frame["I3MCTree"] # get tracks in ice/water mctracksinice = mctree.get_filter(lambda p: p.location_type==p.InIce) mcmuontrack = None highestEnergy=-1. for track in mctracksinice: if track.energy > highestEnergy: highestEnergy = track.energy mcmuontrack = track if mcmuontrack is None: mcmuontrack = dataclasses.I3Particle() primary = dataclasses.get_most_energetic_primary(mctree) if primary is None: primary = dataclasses.I3Particle() frame["MCMostEnergeticInIce"] = mcmuontrack frame["MCMostEnergeticPrimary"] = primary
from icecube.dataclasses import get_most_energetic_cascade from icecube.dataclasses import get_most_energetic_inice from icecube.dataclasses import get_most_energetic from icecube.dataclasses import get_most_energetic_track from icecube.dataclasses import get_most_energetic_cascade from icecube.dataclasses import get_most_energetic_neutrino from icecube.dataclasses import get_most_energetic_muon from icecube.dataclasses import get_most_energetic_nucleus primary = dc.I3Particle() primary.energy = 10 * I3Units.TeV tree = dc.I3MCTree() tree.add_primary(primary) mep = get_most_energetic_primary(tree) I3Test.ENSURE(mep.id == primary.id, "got the wrong particle.") I3Test.ENSURE(not get_most_energetic_cascade(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_inice(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_track(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_neutrino(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_muon(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_nucleus(tree), "got a particle, but shouldn't.") primary2 = dc.I3Particle() primary2.energy = 9 * I3Units.TeV cascade = dc.I3Particle() cascade.type = dc.I3Particle.EMinus
def do_things(frame): """Retrieve and calculate frames from an i3 file. Args: frame (i3 frame): i3 frame from i3 file. Returns: i3 object: i3 object with requested frames. """ cond1 = frame['I3EventHeader'].sub_event_stream != 'InIceSplit' cond2 = 'LineFit' not in frame or 'ToI' not in frame cond3 = 'SRTInIcePulses' not in frame cond4 = not frame['L5_oscNext_bool'] final_cond = cond1 or cond2 or cond3 or cond4 if final_cond: return False else: linefit_result = frame['LineFit'] linefit_fit_status = linefit_result.fit_status toi_result = frame['ToI'] toi_fit_status = toi_result.fit_status try: retro_crs_prefit_result = frame[ 'retro_crs_prefit__median__neutrino' ] retro_crs_prefit_status = frame[ 'retro_crs_prefit__fit_status' ][0] except Exception: return False if linefit_fit_status != 0: return False elif toi_fit_status != 0: return False elif retro_crs_prefit_status != 0: return False hit_stats = frame['HitStatisticsValues'] hit_mult = frame['HitMultiplicityValues'] data['dom_n_hit_multiple_doms'].append( hit_mult.n_hit_doms - hit_mult.n_hit_doms_one_pulse ) time_char = frame['TimeCharacteristicsValues'] data['dom_timelength_fwhm'].append(time_char.timelength_fwhm) # TODO Could we maybe do this in a smarter, programmatic way? # Get the true muon particle # Note that the muon is really produced in the atmosphere, but for the # simulation it is generated at the surface of a cylinder # surrounding IceCube # <icecube.dataclasses.I3Particle> true_primary = dataclasses.get_most_energetic_primary( frame['I3MCTree'] ) true_muon = dataclasses.get_most_energetic_muon(frame['I3MCTree']) if true_muon == None: data['secondary_track_length'].append(np.nan) else: data['secondary_track_length'].append(true_muon.length) # Add the muon energy (defined at the generation cylinder) to the # data dicitonary data['true_primary_energy'].append(np.log10(true_primary.energy)) # Direction of the muon # <icecube.dataclasses.I3Particle> true_primary_direction = true_primary.dir # Add the muon direction to the data dictionary data['true_primary_direction_x'].append(true_primary_direction.x) data['true_primary_direction_y'].append(true_primary_direction.y) data['true_primary_direction_z'].append(true_primary_direction.z) data['true_primary_time'].append(true_primary.time) data['true_primary_speed'].append(true_primary.speed) # Point on the generation cylinder at which the muon is produced # <icecube.dataclasses.I3Particle> true_primary_entry_position = true_primary.pos # Add the entry position to the data dictionary data['true_primary_position_x'].append( true_primary_entry_position.x ) data['true_primary_position_y'].append( true_primary_entry_position.y ) data['true_primary_position_z'].append( true_primary_entry_position.z ) # Get the uncleaned pulses # <icecube.dataclasses.I3RecoPulseSeriesMap> uncleaned_pulses = frame['SplitInIcePulses'].apply(frame) cleaned_pulses = frame['SRTInIcePulses'].apply(frame) dom_geom = frame['I3Geometry'].omgeo # Create empty lists for holding the pulse information temp = np.empty((0, 11)) dom_key_temp = [] # dom_x_temp = np.empty(0) # dom_y_temp = np.empty(0) # dom_z_temp = np.empty(0) # dom_time_temp = np.empty(0) # dom_charge_temp = np.empty(0) # dom_lc_temp = np.empty(0) # dom_atwd_temp = np.empty(0) # dom_fadc_temp = np.empty(0) # dom_pulse_width_temp = np.empty(0) # Go through all pulses, get OM key and pair with time and charge info for entry in uncleaned_pulses.items(): cleaned_time_list = [] this_om_key = entry[0] if this_om_key in cleaned_pulses.keys(): cleaned_temp = cleaned_pulses[this_om_key] for cleaned_entry in cleaned_temp: cleaned_time_list.append(cleaned_entry.time) # This grabs you an object containing the geometry for this # particular OM this_om_geom = dom_geom[this_om_key] # This has x,y,z members this_om_position = this_om_geom.position for i, pulse in enumerate(entry[1]): if pulse.time in cleaned_time_list: cleaned_mask = 1 else: cleaned_mask = 0 # dom_x_temp = np.append(dom_x_temp, this_om_position.x) # dom_y_temp = np.append(dom_y_temp, this_om_position.y) # dom_z_temp = np.append(dom_z_temp, this_om_position.z) # dom_time_temp = np.append(dom_time_temp, pulse.time) # dom_charge_temp = np.append(dom_charge_temp, pulse.charge) # dom_lc_temp = np.append(dom_lc_temp, (pulse.flags & 0x1) >> 0) # dom_atwd_temp = np.append( # dom_atwd_temp, # (pulse.flags & 0x2) >> 1 # ) # dom_fadc_temp = np.append( # dom_fadc_temp, # (pulse.flags & 0x4) >> 2 # ) # dom_pulse_width_temp = np.append( # dom_pulse_width_temp, # pulse.width # ) dom_key = str(this_om_key[0]) + '_' + str(this_om_key[1]) + '_' + str(this_om_key[2]) pulses = np.array( [ this_om_position.x, this_om_position.y, this_om_position.z, pulse.time, pulse.charge, (pulse.flags & 0x1) >> 0, (pulse.flags & 0x2) >> 1, (pulse.flags & 0x4) >> 2, pulse.width, 1, cleaned_mask ], ndmin=2 ) temp = np.append( temp, pulses, axis=0 ) dom_key_temp.append(dom_key) # Add Numpy arrays to data dictionary # data['dom_x'].append(dom_x_temp) # data['dom_y'].append(dom_y_temp) # data['dom_z'].append(dom_z_temp) # data['dom_time'].append(dom_time_temp) # data['dom_charge'].append(dom_charge_temp) # data['dom_lc'].append(dom_lc_temp) # data['dom_atwd'].append(dom_atwd_temp) # data['dom_fadc'].append(dom_fadc_temp) # data['dom_pulse_width'].append(dom_pulse_width_temp) # data['dom_key'].append(np.array(dom_key_temp)) dom_key_temp = np.array(dom_key_temp) dom_key_temp = dom_key_temp[temp[:, 3].argsort()] data['dom_key'].append(dom_key_temp) temp = temp[temp[:, 3].argsort()] data['dom_x'].append(temp[:, 0]) data['dom_y'].append(temp[:, 1]) data['dom_z'].append(temp[:, 2]) data['dom_time'].append(temp[:, 3]) data['dom_charge'].append(temp[:, 4]) data['dom_lc'].append(temp[:, 5]) data['dom_atwd'].append(temp[:, 6]) data['dom_fadc'].append(temp[:, 7]) data['dom_pulse_width'].append(temp[:, 8]) flatten = lambda l: [item for sublist in l for item in sublist] split_indices = np.argwhere(temp[:, 9]) split_indices = np.array(flatten(split_indices)) srt_indices = np.array(np.argwhere(temp[:, 10])) srt_indices = np.array(flatten(srt_indices)) masks['SplitInIcePulses'].append(split_indices) masks['SRTInIcePulses'].append(srt_indices) # Get the cleaned pulses (if available) # <icecube.dataclasses.I3RecoPulseSeriesMap> # cleaned_pulses = frame['SRTInIcePulses'].apply(frame) # Get the LineFit reconstruction # The direction of the straight line # <icecube.dataclasses.I3Particle> linefit_direction = linefit_result.dir # Add the direction of the linefit to the data dictionary data['linefit_direction_x'].append(linefit_direction.x) data['linefit_direction_y'].append(linefit_direction.y) data['linefit_direction_z'].append(linefit_direction.z) # An arbitrary point along the line # <icecube.dataclasses.I3Particle> linefit_point_on_line = linefit_result.pos # Add the arbitrary point along the line to the data dictionary data['linefit_point_on_line_x'].append(linefit_point_on_line.x) data['linefit_point_on_line_y'].append(linefit_point_on_line.y) data['linefit_point_on_line_z'].append(linefit_point_on_line.z) # Some additional params # <icecube.recclasses.I3LineFitParams> # linefit_params = frame['LineFitParams'] # Get the tensor of inertia # The direction of the ToI # <icecube.dataclasses.I3Particle> toi_direction = toi_result.dir # Add the direction to the data dictionary data['toi_direction_x'].append(toi_direction.x) data['toi_direction_y'].append(toi_direction.y) data['toi_direction_z'].append(toi_direction.z) # An arbitrary point along the line # <icecube.dataclasses.I3Particle> toi_point_on_line = toi_result.pos # Add arbitrary point along the line to data dictionary data['toi_point_on_line_x'].append(toi_point_on_line.x) data['toi_point_on_line_y'].append(toi_point_on_line.y) data['toi_point_on_line_z'].append(toi_point_on_line.z) # Some additional params # <icecube.recclasses.I3TensorOfInertiaFitParams> toi_params = frame['ToIParams'] # This is the ratio of the smallest component of the ToI to the sum of # them all. A value close to 0. means a track-like event. # Addd it to the data dictionary data['toi_evalratio'].append(toi_params.evalratio) retro_crs_prefit_position = retro_crs_prefit_result.pos retro_crs_prefit_direction = retro_crs_prefit_result.dir data['retro_crs_prefit_x'].append(retro_crs_prefit_position.x) data['retro_crs_prefit_y'].append(retro_crs_prefit_position.y) data['retro_crs_prefit_z'].append(retro_crs_prefit_position.z) data['retro_crs_prefit_azimuth'].append(retro_crs_prefit_direction.azimuth) data['retro_crs_prefit_zenith'].append(retro_crs_prefit_direction.zenith) data['retro_crs_prefit_energy'].append(retro_crs_prefit_result.energy) data['retro_crs_prefit_time'].append(retro_crs_prefit_result.time)
def Make_Image(frame): global data global geometry global st_info #Log id info id = np.zeros(1,dtype = id_dtype) H = frame["I3EventHeader"] id[["run_id","sub_run_id","event_id","sub_event_id"]] = (H.run_id,H.sub_run_id,H.event_id,H.sub_event_id) #Log Weight info weight = np.zeros(1,dtype = weight_dtype) if data_type in ['genie', 'corsika']: w = dict(frame[WEIGHT_KEY]) weight[list(w.keys())] = tuple(w.values()) #Log MCTree info primary = np.zeros(1,dtype = particle_dtype) prim_daughter = np.zeros(1,dtype = particle_dtype) if not data_type == 'data': #find primary particle mctree = frame[MCTREE_KEY] daughter = None if data_type == 'genie': prim = dataclasses.get_most_energetic_neutrino(mctree) max_energy = 0 for part in mctree.children(prim.id): if part.energy > max_energy: max_enegy = part.energy daughter = part else: prim = dataclasses.get_most_energetic_primary(mctree) daughter = dataclasses.get_most_energetic_muon(mctree) #if no children, then daughter is a duplicate of primary if daughter is None: print("MCTree has no primary children") primary[["tree_id","pdg","energy","position","direction","time","length"]] =\ ([prim.id.majorID, prim.id.minorID], prim.pdg_encoding, prim.energy,\ [prim.pos.x,prim.pos.y,prim.pos.z],\ [prim.dir.zenith,prim.dir.azimuth],prim.time, prim.length) prim_daughter[["tree_id","pdg","energy","position","direction","time","length"]] =\ ([prim.id.majorID, prim.id.minorID], prim.pdg_encoding, prim.energy,\ [prim.pos.x,prim.pos.y,prim.pos.z],\ [prim.dir.zenith,prim.dir.azimuth], prim.time, prim.length) #if there are children, daughter is the child with highest energy else: primary[["tree_id","pdg","energy","position","direction","time","length"]] =\ ([prim.id.majorID, prim.id.minorID], prim.pdg_encoding, prim.energy,\ [prim.pos.x,prim.pos.y,prim.pos.z],\ [prim.dir.zenith,prim.dir.azimuth],prim.time, prim.length) prim_daughter[["tree_id","pdg","energy","position","direction","time","length"]] =\ ([daughter.id.majorID, daughter.id.minorID], daughter.pdg_encoding,daughter.energy,\ [daughter.pos.x,daughter.pos.y,daughter.pos.z],\ [daughter.dir.zenith,daughter.dir.azimuth],daughter.time,daughter.length) #Log HESE veto perameters hese = np.zeros(1,dtype = hese_dtype) hese_vheselfveto = True hese_pos =[-9999,-9999,-9999] hese_time = -999 if frame.Has("HESE3_VHESelfVeto"): hese_vheselfveto = frame["HESE3_VHESelfVeto"].value hese_pos = [frame["HESE3_VHESelfVetoVertexPos"].x,frame["HESE3_VHESelfVetoVertexPos"].y,frame["HESE3_VHESelfVetoVertexPos"].z] hese_time = frame["HESE3_VHESelfVetoVertexTime"].value hese[["vheselfveto","vheselfvetovertexpos","vheselfvetovertextime"]][0] =\ (hese_vheselfveto,hese_pos,hese_time) #Log logan's veto parameters veto = np.zeros(1,dtype = veto_dtype) veto_cas_rlogl = -999 veto_spe_rlogl = 999 veto_cas_rlogl_ndc = -999 veto_spe_rlogl_ndc = 999 veto_fh_z = -999 veto_svv_z = -999 veto_ldp = -999 if frame.Has('HESE3_VHESelfVetoVertexPos') and frame.Has('SPEFit32_DPFitParams') and frame.Has('CascadeLlhVertexFit_DPParams')\ and frame.Has('SPEFit32_noDC_DPFitParams') and frame.Has('CascadeLlhVertexFit_noDC_DPParams') and frame.Has('depthFirstHit')\ and frame.Has("LeastDistanceToPolygon_Veto"): veto_cas_rlogl = frame['CascadeLlhVertexFit_DPParams'].ReducedLlh veto_spe_rlogl = frame['SPEFit32_DPFitParams'].rlogl veto_cas_rlogl_ndc = frame['CascadeLlhVertexFit_noDC_DPParams'].ReducedLlh veto_spe_rlogl_ndc = frame['SPEFit32_noDC_DPFitParams'].rlogl veto_fh_z = frame['depthFirstHit'].value veto_svv_z = frame['HESE3_VHESelfVetoVertexPos'].z veto_ldp = frame["LeastDistanceToPolygon_Veto"].value trck = frame['CascadeLlhVertexFit_DP'] cscd = frame['SPEFit32_DP'] veto[["SPE_rlogl","Cascade_rlogl","SPE_rlogl_noDC", "Cascade_rlogl_noDC","FirstHitZ","VHESelfVetoVertexPosZ","LeastDistanceToPolygon_Veto"]] =\ (veto_spe_rlogl,veto_cas_rlogl,veto_spe_rlogl_ndc,veto_cas_rlogl_ndc,veto_fh_z,veto_svv_z,veto_ldp) pulses= dataclasses.I3RecoPulseSeriesMap.from_frame(frame, PULSES_KEY) wf_map = frame["CalibratedWaveformsHLCATWD"] #make image from raw waveforms wfms = [] wf_times = [] #storage for waveforms starting times wf_widths = [] #storage for waveform bin widths for img_ch, (q, stnum, dist) in enumerate(st_info): for omkey in wf_map.keys(): if (omkey.string == stnum): for wf in wf_map.get(omkey, []): if wf.status == 0 and wf.source_index == 0: wf_times.append(wf.time) wf_widths.append(wf.bin_width) wfms.append({ 'wfm': wf.waveform, 'time': wf.time, 'width': wf.bin_width, 'dom_idx': omkey.om - 1, 'img_ch': img_ch, 'om_pos': [geometry[omkey].position.x,geometry[omkey].position.y,geometry[omkey].position.z] }) im = np.zeros(shape=(N_X_BINS, N_Y_BINS, N_CHANNELS)) wf_times_arr = np.zeros(shape=(N_Y_BINS, N_CHANNELS)) wf_pos_arr = np.zeros(shape=(3,N_Y_BINS, N_CHANNELS)) if len(wfms) <= 4: print("FAILED only %d WF" %len(wfms) ) return False #we neeed to prevent early noise hits from shifting the actual #interaction from the image time frame #first work out when the first waveforn starts wf_times = np.array(wf_times) wf_times = wf_times[wf_times.argsort()] #find the biggest differnece between starting times diff_times = np.diff(wf_times[:N_NOISE_HITS]) max_diff_pos = np.argmax(diff_times) #check if the images needs to be shifted and work out the shift if diff_times[max_diff_pos] > MAX_TIME_SHIFT: min_time = wf_times[max_diff_pos+1] else: min_time = wf_times[0] #make images for wfm in wfms: wf_shift = 0 start_ind = min(N_X_BINS, int((wfm['time'] - min_time) / wfm['width'])) if start_ind >= 0: end_ind = min(N_X_BINS, start_ind + len(wfm['wfm'])) wfm_vals = wfm['wfm'][0:end_ind-start_ind] else: wf_shift = abs(start_ind) start_ind = 0 end_ind = min(N_X_BINS, len(wfm['wfm'])-wf_shift) if end_ind <0: end_ind = 0 wfm_vals = wfm['wfm'][wf_shift:len(wfm['wfm'])] im[start_ind:end_ind, wfm['dom_idx'], wfm['img_ch']] = wfm_vals wf_times_arr[wfm['dom_idx'], wfm['img_ch']] = wfm['time'] wf_pos_arr[0:3,wfm['dom_idx'], wfm['img_ch']] = wfm['om_pos'] if wf_shift > 0: print("the images were shifted by {0:.3f}".format(wf_shift)) im = np.true_divide(im, 10**(-8)) im = im.astype(np.float32) if np.sum(im[:,:,0])==0: print("FAILED no image 0") return False if np.sum(im[:,:,1])==0: print("FAILED no image 1") return False if np.sum(im[:,:,2])==0: print("FAILED no image 2") return False #Log all the event info event = np.zeros(1,dtype = info_dtype) event[["id","image","qtot","qst","primary","prim_daughter","logan_veto","hese","weight_dict"]]=\ (id[0], im, qtot, st_info, primary[0], prim_daughter[0], veto[0],hese[0], weight[0]) data.append(event)
def primary_info(fr): print(dataclasses.get_most_energetic_primary(fr['I3MCTree']))
if not frame.Has("L4BDT"): continue if not frame["L4BDT"]["BDTScore"] > 0.04: continue # Lets just weight to H3a for now w = frame["GaisserH3aWeight"].value if "9036" in filename: w /= 100000.0 elif "9255" in filename: w /= 95000.0 elif "10282" in filename w /= 11200.0 elif "10309" in filename w /= 12200.0 elif "10369" in filename w /= 400.0 elif "11905" in filename w /= 90000.0 elif "12268" in filename w /= 96000.0 elif "12332" in filename w /= 99000.0 # Now, we want the primary. Let's get it primary = dataclasses.get_most_energetic_primary(frame["I3MCTree"]) muon = dataclasses.get_most_energetic_muon(frame["I3MCTree"]) # Propagate the muons muons to the MuonGun generating surface outSurface = Cylinder(1600*I3Units.m, 800*I3Units.m) partVec = MuonGun.muons_at_surface(frame, outSurface) muongun_energy = 1e-9 for p in partVec: if p.energy > muongun_energy: muongun_energy = p.energy weights.append(w) energy_of_primary.append(primary.energy) energy_at_depth.append(muongun_energy)
def DAQ(self, frame): if frame.Has("I3MCTree"): MCprimary = dataclasses.get_most_energetic_primary( frame["I3MCTree"]) MCmuon = dataclasses.get_most_energetic_muon(frame["I3MCTree"]) histo_MCPrimary_x.Fill(MCprimary.pos.x) histo_MCPrimary_y.Fill(MCprimary.pos.y) histo_MCPrimary_z.Fill(MCprimary.pos.z) histo_MCPrimary_xy.Fill(MCprimary.pos.x, MCprimary.pos.y) histo_MCPrimary_xz.Fill(MCprimary.pos.x, MCprimary.pos.z) histo_MCPrimary_yz.Fill(MCprimary.pos.y, MCprimary.pos.z) histo_MC_angle.Fill( phys_services.I3Calculator.angle(MCprimary, MCmuon)) histo_MC_energy_angle.Fill( numpy.log10(MCprimary.energy), phys_services.I3Calculator.angle(MCprimary, MCmuon)) if frame.Has("WIMP_params"): wimp_params = frame["WIMP_params"] histo_wimp_params_nu_weight.Fill(wimp_params.nu_weight) histo_wimp_params_lep_weight.Fill( numpy.log10(wimp_params.lep_weight)) histo_wimp_params_had_weight.Fill( numpy.log10(wimp_params.had_weight)) histo_wimp_params_vgen.Fill(wimp_params.vgen) histo_wimp_params_time.Fill( float(wimp_params.time.mod_julian_day_double)) if frame.Has("WIMP_params") and frame.Has("I3MCTree"): histo_wimp_params_time_nuweight.Fill( float(wimp_params.time.mod_julian_day_double), wimp_params.nu_weight) histo_MCPrimary_zenith_nuweight.Fill(MCprimary.dir.zenith, wimp_params.nu_weight) histo_MCPrimary_azimuth_nuweight.Fill(MCprimary.dir.azimuth, wimp_params.nu_weight) histo_MCPrimary_energy_nuweight.Fill( numpy.log10(MCprimary.energy), wimp_params.nu_weight) histo_MCMuon_zenith_nuweight.Fill(MCmuon.dir.zenith, wimp_params.nu_weight) histo_MCMuon_azimuth_nuweight.Fill(MCmuon.dir.azimuth, wimp_params.nu_weight) histo_MCMuon_energy_nuweight.Fill(numpy.log10(MCmuon.energy), wimp_params.nu_weight) histo_MC_angle_lepweight.Fill( phys_services.I3Calculator.angle(MCprimary, MCmuon), wimp_params.lep_weight) histo_MC_nuenergy_angle_lepweight.Fill( numpy.log10(MCprimary.energy), phys_services.I3Calculator.angle(MCprimary, MCmuon), wimp_params.lep_weight) histo_MC_muenergy_angle_lepweight.Fill( numpy.log10(MCmuon.energy), phys_services.I3Calculator.angle(MCprimary, MCmuon), wimp_params.lep_weight) histo_nuenergy_lepweight.Fill( numpy.log10(MCprimary.energy), numpy.log10(wimp_params.lep_weight)) histo_nuenergy_lepweight_lepweight.Fill( numpy.log10(MCprimary.energy), numpy.log10(wimp_params.lep_weight), wimp_params.lep_weight) self.PushFrame(frame) return
from icecube.dataclasses import get_most_energetic_primary from icecube.dataclasses import get_most_energetic_cascade from icecube.dataclasses import get_most_energetic_inice from icecube.dataclasses import get_most_energetic from icecube.dataclasses import get_most_energetic_track from icecube.dataclasses import get_most_energetic_cascade from icecube.dataclasses import get_most_energetic_neutrino from icecube.dataclasses import get_most_energetic_muon from icecube.dataclasses import get_most_energetic_nucleus primary = dc.I3Particle() primary.energy = 10 * I3Units.TeV tree = dc.I3MCTree() tree.add_primary(primary) mep = get_most_energetic_primary(tree) I3Test.ENSURE(mep.id == primary.id, "got the wrong particle.") I3Test.ENSURE(not get_most_energetic_cascade(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_inice(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_track(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_neutrino(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_muon(tree), "got a particle, but shouldn't.") I3Test.ENSURE(not get_most_energetic_nucleus(tree), "got a particle, but shouldn't.")