def check_type(frame): del frame["IsCascade_true"] del frame["IsTrack_true"] frame["IsCascade_true"]= icetray.I3Bool(False) frame["IsTrack_true"]= icetray.I3Bool(True) if frame["IsHese"].value==False: del frame["IsCascade_reco"] del frame["IsTrack_reco"] if frame["L4StartingTrackHLCSplitVetoCharge"].value>2.5: frame["IsTrack_reco"]=icetray.I3Bool(True) frame["IsCascade_reco"]=icetray.I3Bool(False) else: frame["IsTrack_reco"]=icetray.I3Bool(False) frame["IsCascade_reco"]=icetray.I3Bool(True) else: if frame["L4StartingTrackHLCSplitVetoCharge"].value<1.: del frame["IsCascade_reco"] del frame["IsTrack_reco"] frame["IsTrack_reco"]=icetray.I3Bool(False) frame["IsCascade_reco"]=icetray.I3Bool(True) elif frame["L4StartingTrackHLCSplitVetoCharge"].value>100.: del frame["IsCascade_reco"] del frame["IsTrack_reco"] frame["IsTrack_reco"]=icetray.I3Bool(True) frame["IsCascade_reco"]=icetray.I3Bool(False)
def DAQ(self, frame): particle = frame['MCMuon'] v_dir = np.array([particle.dir.x, particle.dir.y, particle.dir.z]) v_pos = np.array(particle.pos) distances = np.linalg.norm(np.cross(v_dir, v_pos - self.dom_positions), axis=1) self.min_distances.append(min(distances)) if self.relevance_dist is not None: n_relevant_doms = distances < self.relevance_dist already_added = False for i, stream_i in enumerate(self.stream_objects): if i == self.default_idx: continue if already_added: is_in_stream = False else: if stream_i.dom_limit < 1.: limit_i = n_relevant_doms * stream_i.dom_limit else: limit_i = stream_i.dom_limit is_in_stream = np.sum( distances < stream_i.distance_cut) >= limit_i frame[stream_i.stream_name] = icetray.I3Bool(is_in_stream) if is_in_stream: self.hist[i] += 1 already_added = True if self.default_idx is not None: if already_added and self.default_idx is not None: frame['MCOversizeStreamDefault'] = icetray.I3Bool(False) else: self.hist[self.default_idx] += 1 frame['MCOversizeStreamDefault'] = icetray.I3Bool(True) self.PushFrame(frame)
def DAQ(self, frame): if self.simulation_type == 'muongun': particle_list = [frame['MCMuon']] check_starting = False check_stopping = False elif self.simulation_type == 'nue': particle_list = get_nue_particles(frame, frame['NuGPrimary']) check_starting = False check_stopping = False elif self.simulation_type == 'numu': particle_list = get_numu_particles(frame, frame['NuGPrimary']) check_starting = True check_stopping = True stream_list = [] for p in particle_list: distances = self.get_distances(frame, p, check_starting=check_starting, check_stopping=check_stopping) if self.relevance_dist is not None: n_relevant_doms = distances < self.relevance_dist else: n_relevant_doms = self.dom_positions.shape[0] for i, stream_i in enumerate(self.stream_objects): if stream_i.dom_limit < 1.: limit_i = n_relevant_doms * stream_i.dom_limit else: limit_i = stream_i.dom_limit if np.sum(distances < stream_i.distance_cut) >= limit_i: stream_list.append(stream_i) if self.default_idx is not None: stream_list.append(self.stream_objects[self.default_idx]) selected_stream = None lowest_oversize = None for i, stream_i in enumerate(stream_list): if lowest_oversize is None: lowest_oversize = stream_i.oversize_factor selected_stream = stream_i else: if stream_i.oversize_factor < lowest_oversize: selected_stream = stream_i lowest_oversize = stream_i.oversize_factor for stream_i in self.stream_objects: if stream_i is selected_stream: frame[stream_i.stream_name] = icetray.I3Bool(True) else: frame[stream_i.stream_name] = icetray.I3Bool(False) self.PushFrame(frame)
def final_filter(frame): #if 'MuonWeight_GaisserH4a' not in frame: # frame['MuonWeight_GaisserH4a']=dataclasses.I3Double(0.) ########### ## HESE ########### if (frame["L4VetoLayer0"].value + frame["L4VetoLayer1"].value < 3 and frame["HomogenizedQTot"].value > 6000. ) or frame["IsHESE_ck"].value == True: frame["IsHese"] = icetray.I3Bool(True) frame["IsCascade"] = icetray.I3Bool(False) frame["IsUpgoingMuon"] = icetray.I3Bool(False) print(frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id, " HESE" ) #, frame['MuonWeight_GaisserH4a'].value*3600*24*340/160000 return True else: frame["IsHese"] = icetray.I3Bool(False) ########### ## CASCADES ########### if frame["L4VetoTrackOfflineVetoCharge"].value < 2 or frame[ "L4VetoTrackSplitVetoCharge"].value < 2 or frame[ "L4VetoTrackMilliOfflineVetoCharge"].value < 2 or frame[ "L4VetoTrackMilliSplitVetoCharge"].value < 2: frame["IsUpgoingMuon"] = icetray.I3Bool(False) frame["IsCascade"] = icetray.I3Bool(True) print(frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id, " CASCADE", frame['HomogenizedQTot'].value ) #, frame['MuonWeight_GaisserH4a'].value*3600*24*340/160000 return True else: frame["IsCascade"] = icetray.I3Bool(False) ########### ## UPMU ########### if ( frame['L4UpgoingTrackOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackOfflineVetoCharge'].value > \ frame['L4VetoTrackOfflineVetoCharge'].value and frame['L4UpgoingTrackOfflineVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackSplitVetoCharge'].value > 10 and frame['L4UpgoingTrackSplitVetoCharge'].value > \ frame['L4VetoTrackSplitVetoCharge'].value and frame['L4UpgoingTrackSplitVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackMilliSplitVetoCharge'].value > 10 and frame['L4UpgoingTrackMilliSplitVetoCharge'].value > \ frame['L4VetoTrackMilliSplitVetoCharge'].value and frame['L4UpgoingTrackMilliSplitVetoChannels'].value > 3 or \ ( frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > \ frame['L4VetoTrackMilliOfflineVetoCharge'].value and frame['L4UpgoingTrackMilliOfflineVetoChannels'].value > 3 )): frame["IsUpgoingMuon"] = icetray.I3Bool(True) print("Upgoing Muon event!", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) else: frame["IsUpgoingMuon"] = icetray.I3Bool(False) return frame["IsUpgoingMuon"].value == True or frame[ "IsHese"].value == True or frame["IsCascade"].value == True
def create_filter_values(frame): ''' Store FilerMask values regarding DeepCore into doubles so that they're still available when i3 files are converted to hdf5. ''' try: dc = frame['FilterMask']['DeepCoreFilter_13'].condition_passed ext_dc = frame['FilterMask'][ 'DeepCoreFilter_TwoLayerExp_13'].condition_passed frame['DC_passed'] = icetray.I3Bool(dc) frame['EXT_passed'] = icetray.I3Bool(ext_dc) except: print('FilterMask not found.')
def MarkFrameForSubThresholdVeto(frame): any_in_frame = ("HESE_VHESelfVeto" in frame) or ("HESE_VHESelfVetoVertexTime" in frame) or ("HESE_VHESelfVetoVertexPos" in frame) all_in_frame = ("HESE_VHESelfVeto" in frame) and ( "HESE_VHESelfVetoVertexTime" in frame) and ("HESE_VHESelfVetoVertexPos" in frame) if all_in_frame: # all good frame["HESE_VertexThreshold"] = dataclasses.I3Double(250.) elif any_in_frame: print(frame) raise RuntimeError( "Some of the HESE veto objects exist but not all of them. This is an error." ) else: print( " ******* VERY LOW CHARGE EVENT - re-doing HESE veto with much lower pe vertex threshold to at least get a seed position ******* " ) # Re-do this with 10pe, but let people looking at the resulting # frame know! (the resulting veto condition is basically meaningless) frame["HESE_VertexThreshold"] = dataclasses.I3Double(5.) frame["HESE_VHESelfVeto"] = icetray.I3Bool(False)
def Physics(self, frame): if self.loudest not in frame: self.PushFrame(frame) return loud = frame[self.loudest] # is an I3Double or I3VectorInt edge = False if self.config not in self.edgeDict.keys(): raise RuntimeError('Unknown config, Please choose from IT40-IT81') edgeList = self.edgeDict[self.config] # Check if loudest station on edge if loud.__class__ == dc.I3Double: if loud.value in edgeList: edge = True # Check if any saturated stations on edge elif loud.__class__ == dc.I3VectorInt: for station in loud: if station in edgeList: edge = True output = icetray.I3Bool(edge) frame[self.outputName] = output self.PushFrame(frame)
def lap_fitstatus_ok(frame): status_ok = False if 'Laputop' in frame: lap_particle = frame['Laputop'] if (lap_particle.fit_status == dataclasses.I3Particle.OK): status_ok = True frame.Put('Laputop_fitstatus_ok', icetray.I3Bool(status_ok))
def check_volume(frame): from shapely.geometry import Point from shapely.geometry.polygon import Polygon # "Check whether the interaction vertex is inside the instrumented volume for the case of neutrinos" # # "Check whether the muon or its secondaries go inside the instrumented volume anytime # #Geo coordinates must be sorted to close the area in x,y. String in the middle is therefore not included #v47 #z_min = -450 #z_max = -200 #x_coord = numpy.array([-5.55,9.63,26.22,32.43,8.14,-14.30]) #y_coord = numpy.array([-20.96,2.11,-12.59,-54.81,-69.23,-45.57]) #v53 z_min = -480 z_max = -200 x_coord = numpy.array([26.96, 62.62, 89.29, 57.29, 14.29, 18.29]) y_coord = numpy.array([-31.19, -35.16,-59.00, -83.69, -80.56,-51.05]) x_y = numpy.column_stack((x_coord,y_coord)) polygon = Polygon(x_y) tree = frame["I3MCTree"] truth = frame["I3MCTree"][0] truth_type = str(truth.type) if truth_type == "unknown" or truth_type == "MuMinus" or truth_type == "MuPlus": for particle in tree: x = particle.pos.x/I3Units.m y = particle.pos.y/I3Units.m z = particle.pos.z/I3Units.m point = Point(x,y) if z > z_min and z< z_max and polygon.contains(point): frame.Put('MyContainmentFilter', icetray.I3Bool(True)) return True frame.Put('MyContainmentFilter', icetray.I3Bool(False)) return False else: x = truth.pos.x/I3Units.m y = truth.pos.y/I3Units.m z = truth.pos.z/I3Units.m point = Point(x,y) if z > z_min and z< z_max and polygon.contains(point): frame.Put('MyContainmentFilter', icetray.I3Bool(True)) return True else: frame.Put('MyContainmentFilter', icetray.I3Bool(False)) return False
def check_type(frame): if "MCPrimary" in frame: if frame["MCPrimary"].type==12 or frame["MCPrimary"].type==-12: frame["IsCascade_true"]= icetray.I3Bool(True) frame["IsTrack_true"]= icetray.I3Bool(False) if (frame["MCPrimary"].type==14 or frame["MCPrimary"].type==-14) and frame["I3MCWeightDict"]["InteractionType"]==2.0: frame["IsCascade_true"]= icetray.I3Bool(True) frame["IsTrack_true"]= icetray.I3Bool(False) elif (frame["MCPrimary"].type==14 or frame["MCPrimary"].type==-14) and frame["I3MCWeightDict"]["InteractionType"]==1.0: frame["IsCascade_true"]= icetray.I3Bool(False) frame["IsTrack_true"]= icetray.I3Bool(True) if (frame["MCPrimary"].type==16 or frame["MCPrimary"].type==-16) and frame["I3MCWeightDict"]["InteractionType"]==2.0: frame["IsCascade_true"]= icetray.I3Bool(True) frame["IsTrack_true"]= icetray.I3Bool(False) elif (frame["MCPrimary"].type==16 or frame["MCPrimary"].type==-16) and frame["I3MCWeightDict"]["InteractionType"]==1.0: frame["IsCascade_true"]= icetray.I3Bool(False) frame["IsTrack_true"]= icetray.I3Bool(True)
def overall_cut(frame): # Data quality # Remove coincident events (not simulated) data_quality_cut = frame[L7_COINCIDENT_REJECTION_BOOL_KEY].value # Muons # Cut on classifier prediction (0.7 gives a muon rate that is ~ the same as the nutau rate) muon_cut = frame[L7_MUON_MODEL_PREDICTION_KEY].value >= 0.7 # Noise noise_cut = True #TODO # Put it all together and add to frame frame[L7_DATA_QUALITY_CUT_BOOL_KEY] = icetray.I3Bool(data_quality_cut) frame[L7_MUON_CUT_BOOL_KEY] = icetray.I3Bool(muon_cut) frame[L7_NOISE_CUT_BOOL_KEY] = icetray.I3Bool(noise_cut) frame[L7_CUT_BOOL_KEY] = icetray.I3Bool(data_quality_cut & muon_cut & noise_cut)
def check_type(frame): del frame["IsCascade_true"] del frame["IsTrack_true"] tree = frame["I3MCTree"] is_track = False for p in tree: if (p.type == -13 or p.type == 13) and p.energy > 500.: is_track = True print( "Outgoing Muon with at least 100 GeV, classifying as track", p.energy) break if is_track == True: print("Outgoing Muon with at least 100 GeV, classifying as track") frame["IsCascade_true"] = icetray.I3Bool(False) frame["IsTrack_true"] = icetray.I3Bool(True) else: frame["IsCascade_true"] = icetray.I3Bool(True) frame["IsTrack_true"] = icetray.I3Bool(False)
def Physics(self, frame): ''' Check if muon from CC is created within detection volumes ''' if len(self.detector_parts.keys()) == 0: raise IOError('You need to provide a gcd file.') primary = get_primary(frame, pdg_type=self._NEUTRINO_TYPE) # neutrino type - 1 = lepton flavour of given neutrino type in_parts = self.is_cc_in_detector(frame, primary, pdg_type=self._NEUTRINO_TYPE - 1) if isinstance(in_parts, list): in_deepcore = True if 'deepcore' in in_parts else False if self._EXTENDED: in_deepcore_ext = True if 'deepcore_ext' in in_parts else False else: in_deepcore = False if self._EXTENDED: in_deepcore_ext = False frame.Put('cc_in_deepcore', icetray.I3Bool(in_deepcore)) if self._EXTENDED: frame.Put('cc_in_deepcore_ext', icetray.I3Bool(in_deepcore_ext)) self.PushFrame(frame)
def FramePacket(self,frames): originalFrame = icetray.I3Frame() #keep this pointer alive targetFrame = icetray.I3Frame() for oframe in frames: if oframe.Has("I3EventHeader") and oframe["I3EventHeader"].sub_event_stream==self.originalStream: originalFrame=oframe for tframe in frames: if tframe.Has("I3EventHeader") and tframe["I3EventHeader"].sub_event_stream==self.targetStream and tframe["I3EventHeader"].sub_event_id==oframe["I3EventHeader"].sub_event_id: targetFrame=tframe for key in self.moveObjects: targetFrame[key]=originalFrame[key] targetFrame.Put(self.flagName, icetray.I3Bool(True)) for frame in frames: self.PushFrame(frame)
def layer_veto_cut(frame): if "HESE_CausalQTot" in frame: if frame["HESE_CausalQTot"].value>6000. and frame["HESE_VHESelfVeto"].value==False: print("HESE (ck) event!", frame["I3EventHeader"].event_id) frame["IsHESE_ck"]=icetray.I3Bool(True) else: frame["IsHESE_ck"]=icetray.I3Bool(False) else: frame["IsHESE_ck"]=icetray.I3Bool(False) nstring = len(set(om.string for om in dataclasses.I3RecoPulseSeriesMap.from_frame(frame, 'SplitInIcePulsesHLC_NoDC').keys())) layer_veto_charge = frame['VetoLayer0'].value + frame['VetoLayer1'].value if nstring>3 and layer_veto_charge<3 and frame['HomogenizedQTot'].value > 6e3: frame["IsHESE_jvs"]=icetray.I3Bool(True) print("HESE (jvs) event!", frame["I3EventHeader"].event_id) return True elif nstring>3 and layer_veto_charge==0 and frame['HomogenizedQTot'].value > 100.: frame["IsHESE_jvs"]=icetray.I3Bool(False) print("Potential MESE event!", layer_veto_charge, frame['HomogenizedQTot'].value, frame['HomogenizedQTot_toposplit'].value, frame["I3EventHeader"].event_id) return True elif frame["IsHESE_ck"].value==True: return True else: return False
def compute_L6_cut(frame): ''' Compute the actual reco stage cut boolean ''' # Check if at least one final level reco was run and was successful # Note that retro does some pre-cleaning of pulses/events, so some events are NOT reco'd due to this # santa_fit_success = False #TODO retro_fit_success = check_retro_reco_success(frame) # Build the final cut # keep_event = santa_fit_success or retro_fit_success #TODO keep_event = retro_fit_success # Add to frame frame[L6_CUT_BOOL_KEY] = icetray.I3Bool(keep_event)
def monopod_based_cuts(frame): CutsPassed = icetray.I3Bool() CutsPassed.value = True mono = frame["TimedMonopodFit12"] #print mono.pos.z, mono.energy, math.sqrt((mono.pos.x-46)**2+(mono.pos.y+34)**2) if mono.pos.z > -180: CutsPassed.value = False if math.sqrt((mono.pos.x - 46)**2 + (mono.pos.y + 34)**2) > 150: CutsPassed.value = False if mono.energy > 200: CutsPassed.value = False frame["NewBgRejCuts"] = CutsPassed if (CutsPassed.value == True): return True else: return False
def Geometry(self, frame): frame['I3Geometry'] = icetray.I3Bool(True) self.PushFrame(frame)
def printy(frame): del frame["MillipedeDepositedEnergy"] del frame["TrackEnergy"] if "MuonLosses" in frame: losses = frame["MuonLosses"] first_loss_found = False deposited_energy = 0 for i in range(0, len(losses)): if losses[i].pos.z < 500 and losses[ i].pos.z > -500 and math.sqrt( losses[i].pos.x * losses[i].pos.x + losses[i].pos.y * losses[i].pos.y) < 550: deposited_energy = deposited_energy + losses[i].energy else: deposited_energy = 0. frame["MillipedeDepositedEnergy"] = dataclasses.I3Double( deposited_energy) frame["TrackEnergy"] = dataclasses.I3Double(deposited_energy) if frame["IsHese"].value == False and frame[ "IsCascade_reco"].value == False and deposited_energy == 0.: return False if frame["IsCascade_reco"] == True and frame[ "L5MonopodFit4"].energy > 6e4: del frame["IsCascade_reco"] del frame["IsTrack_reco"] if frame["TrackLength"] > 550: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) else: frame["IsCascade_reco"] = icetray.I3Bool(True) frame["IsTrack_reco"] = icetray.I3Bool(False) if frame["IsCascade_reco"].value == False and frame[ "TrackEnergy"].value > 6e4: del frame["IsCascade_reco"] del frame["IsTrack_reco"] if frame["TrackLength"] > 550: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) else: frame["IsCascade_reco"] = icetray.I3Bool(True) frame["IsTrack_reco"] = icetray.I3Bool(False) if frame["IsCascade_reco"].value == True and abs( frame["L5MonopodFit4"].pos.z) > 550.: return False if frame["IsHese"].value == True and frame[ "IsHESE_ck"].value == False and frame[ "CascadeFilter"].value == False: #and frame["L4VetoLayer1"].value<10: del frame["IsHese"] frame["IsHese"] = icetray.I3Bool(False) if frame["IsCascade"].value == True and frame[ "IsCascade_reco"].value == True and ( frame["L5MonopodFit4"].pos.z < -500 or frame["L5MonopodFit4"].pos.z > 500 or numpy.sqrt(frame["L5MonopodFit4"].pos.x * frame["L5MonopodFit4"].pos.x + frame["L5MonopodFit4"].pos.y * frame["L5MonopodFit4"].pos.y) > 550): print("Cascade event outside of detector... ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) del frame["IsCascade"] frame["IsCascade"] = icetray.I3Bool(False) if frame["IsCascade"].value == True and frame[ "IsCascade_reco"].value == False and ( frame["L4VetoTrackMilliOfflineVetoCharge"].value > 2 or frame['L4VetoTrackMarginMilliOfflineSide'].value < 125): del frame["IsCascade"] frame["IsCascade"] = icetray.I3Bool(False) if frame["IsUpgoingMuon"].value == True: #print "UpMu event: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id return True elif frame["IsHese"].value == True: print("HESE event: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) return True elif frame["IsCascade"].value == True and frame[ "L4VetoTrackOfflineVetoCharge"].value < 6 and frame[ "L4VetoTrackL5OfflineVetoCharge"].value < 2: #print "Cascade event: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id return True elif frame["IsCascade"].value == True and frame[ "L4VetoTrackOfflineVetoCharge"].value < 2 and frame[ "L4VetoTrackL5OfflineVetoCharge"].value < 3: #print "Cascade event: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id return True else: if ( ( frame['L4UpgoingTrackOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackOfflineVetoCharge'].value > \ frame['L4VetoTrackOfflineVetoCharge'].value and frame['L4UpgoingTrackOfflineVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackSplitVetoCharge'].value > 10 and frame['L4UpgoingTrackSplitVetoCharge'].value > \ frame['L4VetoTrackSplitVetoCharge'].value and frame['L4UpgoingTrackSplitVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > \ frame['L4VetoTrackMilliOfflineVetoCharge'].value and frame['L4UpgoingTrackMilliOfflineVetoChannels'].value > 3 and \ frame['L4UpgoingTrackSplitVetoCharge'].value > 6 ) )\ and frame["TrackFit"].dir.zenith>1.5 and frame["MuonFilter"].value==True:# and frame["OnlineL2Filter"].value==True: del frame["IsUpgoingMuon"] del frame["IsCascade"] frame["IsUpgoingMuon"] = icetray.I3Bool(True) frame["IsCascade"] = icetray.I3Bool(False) #print "UpMu event!", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id return True else: return False
def final_filter(frame): del frame["IsUpgoingMuon"] del frame["IsCascade"] del frame["IsHese"] ########### ## HESE ########### if (frame["L4VetoLayer0"].value+frame["L4VetoLayer1"].value==0 and frame["HomogenizedQTot"].value>6000.) or frame["IsHESE_ck"].value==True: print "HESE event! ",frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id frame["IsHese"]=icetray.I3Bool(True) frame["IsCascade"]=icetray.I3Bool(False) frame["IsUpgoingMuon"]=icetray.I3Bool(False) return True else: frame["IsHese"]=icetray.I3Bool(False) if frame["IsHese"].value==False and frame["HomogenizedQTot"].value>6000.: return False ########### ## CASCADES ########### # MONOPOD WITH OFFLINE PULSES if frame['L4VetoTrackMarginOfflineTop'].value > 100 and frame['L4VetoTrackMarginOfflineSide'].value > 0: side = math.log10(frame['HomogenizedQTot'].value) > 3.40876826865 - ((frame['L4VetoTrackMarginOfflineSide'].value+5)**1.73562251277)/17266.4002818 top = math.log10(frame['HomogenizedQTot'].value) > 3.40214654218 -((frame['L4VetoTrackMarginOfflineTop'].value-100)**1.880562951)/23709.9897396 else: side=False top=False inside_volume_mono_offline = (side and top) # MONOPOD WITH SPLIT PULSES if frame['L4VetoTrackMarginSplitTop'].value > 100 and frame['L4VetoTrackMarginSplitSide'].value > 0: side = math.log10(frame['HomogenizedQTot'].value) > 3.40876826865 - ((frame['L4VetoTrackMarginSplitSide'].value+5)**1.73562251277)/17266.4002818 top = math.log10(frame['HomogenizedQTot'].value) > 3.40214654218 -((frame['L4VetoTrackMarginSplitTop'].value-100)**1.880562951)/23709.9897396 else: side=False top=False inside_volume_mono_split = (side and top) # MILLIPEDE WITH OFFLINE PULSES if frame['L4VetoTrackMarginMilliOfflineTop'].value > 100 and frame['L4VetoTrackMarginMilliOfflineSide'].value > 0: side = math.log10(frame['HomogenizedQTot'].value) > 3.40876826865 - ((frame['L4VetoTrackMarginMilliOfflineSide'].value)**1.73562251277)/17266.4002818 top = math.log10(frame['HomogenizedQTot'].value) > 3.40214654218 -((frame['L4VetoTrackMarginMilliOfflineTop'].value-100)**1.880562951)/23709.9897396 else: side=False top=False inside_volume_milli_offline = (side and top) if frame["IsCascade_reco"].value==True: if frame["CascadeFilter"].value==True and (frame["L4VetoTrackOfflineVetoCharge"].value<2 and \ inside_volume_mono_offline and inside_volume_milli_offline) and \ (numpy.log10(frame["L4MonopodFit"].energy)-numpy.cos(frame["L4MonopodFit"].dir.zenith)>2.5 or \ numpy.cos(frame["L4MonopodFit"].dir.zenith)<0.5): frame["IsCascade"]=icetray.I3Bool(True) frame["IsUpgoingMuon"]=icetray.I3Bool(False) print "CASCADE (cascade): ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id,frame['HomogenizedQTot'].value#, frame['MuonWeight_GaisserH4a'].value*3600*24*340/160000 return True else: frame["IsCascade"]=icetray.I3Bool(False)
if frame["IsCascade_reco"].value==True: if frame["CascadeFilter"].value==True and (frame["L4VetoTrackOfflineVetoCharge"].value<2 and \ inside_volume_mono_offline and inside_volume_milli_offline) and \ (numpy.log10(frame["L4MonopodFit"].energy)-numpy.cos(frame["L4MonopodFit"].dir.zenith)>2.5 or \ numpy.cos(frame["L4MonopodFit"].dir.zenith)<0.5): frame["IsCascade"]=icetray.I3Bool(True) frame["IsUpgoingMuon"]=icetray.I3Bool(False) print "CASCADE (cascade): ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id,frame['HomogenizedQTot'].value#, frame['MuonWeight_GaisserH4a'].value*3600*24*340/160000 return True else: frame["IsCascade"]=icetray.I3Bool(False) else: if (frame["MuonFilter"].value==True and frame["L4VetoTrackMilliOfflineVetoCharge"].value<2 and \ frame["L4VetoTrackOfflineVetoCharge"].value<2 and inside_volume_milli_offline and inside_volume_mono_offline):# or\ #(frame["L4VetoTrackMilliSplitVetoCharge"].value<2 and inside_volume_milli_split): frame["IsCascade"]=icetray.I3Bool(True) frame["IsUpgoingMuon"]=icetray.I3Bool(False) print "CASCADE (track): ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id,frame['HomogenizedQTot'].value#, frame['MuonWeight_GaisserH4a'].value*3600*24*340/160000 return True else: frame["IsCascade"]=icetray.I3Bool(False) ########### ## UPMU ########### if ( ( frame['L4UpgoingTrackOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackOfflineVetoCharge'].value > \ frame['L4VetoTrackOfflineVetoCharge'].value and frame['L4UpgoingTrackOfflineVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackSplitVetoCharge'].value > 10 and frame['L4UpgoingTrackSplitVetoCharge'].value > \ frame['L4VetoTrackSplitVetoCharge'].value and frame['L4UpgoingTrackSplitVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > \ frame['L4VetoTrackMilliOfflineVetoCharge'].value and frame['L4UpgoingTrackMilliOfflineVetoChannels'].value > 3 and \
def passIC2011_LE_L3(frame): IC2011_LE_L3_FrameObjects = [ "DCFilterPulses_VetoPE", "MicroCountHits", "MicroCountPE", "NAbove200", "NoiseEngine_S3bool", "C2QR6", "RTVetoSeries250PE", "SRTTWOfflinePulsesDCFid", "SRTTWOfflinePulsesICVeto", "VertexGuessZ" ] frameObjects = frame.keys() matchingFrameObjects = set(IC2011_LE_L3_FrameObjects).intersection( set(frameObjects)) if len(matchingFrameObjects) == 10 and len(frame["SRTTWOfflinePulsesDCFid"]) > 0: # Count the number of SRT cleaned PEs in the DeepCore fiducial and # IceCube Veto region for use in the Ratio Cut variable. Also, # count the number of PE for hits satisying the DeepCore Filter # `speed of light' criteria. totalChargeFiducial = 0 totalChargeVeto = 0 for omkey in frame["SRTTWOfflinePulsesDCFid"]: for pulse in omkey[1]: totalChargeFiducial += pulse.charge # end for() # end for() for omkey in frame["SRTTWOfflinePulsesICVeto"]: for pulse in omkey[1]: totalChargeVeto += pulse.charge # end for() # end for() LE_L3_Vars = dataclasses.I3MapStringDouble() LE_L3_Vars["NoiseEngine"] = frame["NoiseEngine_S3bool"].value LE_L3_Vars["STW9000_DTW175PE"] = frame["MicroCountPE"].get("STW9000_DTW175") LE_L3_Vars["STW9000_DTW200PE"] = frame["MicroCountPE"].get("STW9000_DTW200") LE_L3_Vars["STW9000_DTW250PE"] = frame["MicroCountPE"].get("STW9000_DTW250") LE_L3_Vars["STW9000_DTW300PE"] = frame["MicroCountPE"].get("STW9000_DTW300") LE_L3_Vars["STW9000_DTW175Hits"] = frame["MicroCountHits"].get("STW9000_DTW175") LE_L3_Vars["STW9000_DTW200Hits"] = frame["MicroCountHits"].get("STW9000_DTW200") LE_L3_Vars["STW9000_DTW250Hits"] = frame["MicroCountHits"].get("STW9000_DTW250") LE_L3_Vars["STW9000_DTW300Hits"] = frame["MicroCountHits"].get("STW9000_DTW300") LE_L3_Vars["C2QR6"] = frame["C2QR6"].value LE_L3_Vars["NAbove200PE"] = frame["NAbove200"].value LE_L3_Vars["DCFiducialPE"] = totalChargeFiducial LE_L3_Vars["ICVetoPE"] = totalChargeVeto LE_L3_Vars["CausalVetoPE"] = frame["DCFilterPulses_VetoPE"].value LE_L3_Vars["CausalVetoHits"] = frame["DCFilterPulses_VetoHits"].value LE_L3_Vars["VertexGuessZ"] = frame["VertexGuessZ"].value LE_L3_Vars["RTVeto250PE"] = frame["RTVetoSeries250PE"].value frame["IC2011_LE_L3_Vars"] = LE_L3_Vars if frame["NoiseEngine_S3bool"].value and frame["MicroCountHits"].get("STW9000_DTW300") > 2 and frame["MicroCountPE"].get("STW9000_DTW300") > 2 and \ frame["C2QR6"].value > 0.4 and frame["NAbove200"].value < 12 and totalChargeVeto*1.0/totalChargeFiducial < 1.5 and frame["VertexGuessZ"].value < -120 and \ frame["DCFilterPulses_VetoPE"].value < 7.0 and ( (frame["RTVetoSeries250PE"].value < 4.0 and LE_L3_Vars["DCFiducialPE"] < 100) or \ (frame["RTVetoSeries250PE"].value < 6.0 and LE_L3_Vars["DCFiducialPE"] >= 100 and LE_L3_Vars["DCFiducialPE"] < 150) or \ (frame["RTVetoSeries250PE"].value < 10.0 and LE_L3_Vars["DCFiducialPE"] >= 150 and LE_L3_Vars["DCFiducialPE"] < 200) or (LE_L3_Vars["DCFiducialPE"] >= 200) ): frame["IC2011_LE_L3"] = icetray.I3Bool(True) return # end if() # end if() frame["IC2011_LE_L3"] = icetray.I3Bool(False) return
def event_filter(frame): #print "Before filter: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id del frame["IsUpgoingMuon"] del frame["IsCascade"] del frame["IsHese"] ########### ## HESE ########### if frame["IsHESE_ck"].value == False and ( frame["L4VetoLayer0"].value + frame["L4VetoLayer1"].value ) == 0 and frame["HomogenizedQTot"].value > 6000. and frame[ "IsCascade_reco"].value == False: frame["IsHese"] = icetray.I3Bool(False) print("Jakob HESE event that's probably a muon removed...") elif (frame["L4VetoLayer0"].value + frame["L4VetoLayer1"].value == 0 and frame["HomogenizedQTot"].value > 6000. ) or frame["IsHESE_ck"].value == True: #print "HESE event! ",frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id frame["IsHese"] = icetray.I3Bool(True) frame["IsCascade"] = icetray.I3Bool(False) frame["IsUpgoingMuon"] = icetray.I3Bool(False) return True else: frame["IsHese"] = icetray.I3Bool(False) if frame["IsHese"].value == False and frame[ "HomogenizedQTot"].value > 6000.: return False ########### ## CASCADES ########### # MONOPOD WITH OFFLINE PULSES if frame['L4VetoTrackMarginOfflineTop'].value > 100 and frame[ 'L4VetoTrackMarginOfflineSide'].value > 0: side = math.log10(frame['HomogenizedQTot'].value) > 3.40876826865 - ( (frame['L4VetoTrackMarginOfflineSide'].value + 5)** 1.73562251277) / 17266.4002818 top = math.log10(frame['HomogenizedQTot'].value) > 3.40214654218 - ( (frame['L4VetoTrackMarginOfflineTop'].value - 100)** 1.880562951) / 23709.9897396 else: side = False top = False inside_volume_mono_offline = (side and top) # MONOPOD WITH SPLIT PULSES if frame['L4VetoTrackMarginSplitTop'].value > 100 and frame[ 'L4VetoTrackMarginSplitSide'].value > 0: side = math.log10(frame['HomogenizedQTot'].value) > 3.40876826865 - ( (frame['L4VetoTrackMarginSplitSide'].value + 5)** 1.73562251277) / 17266.4002818 top = math.log10(frame['HomogenizedQTot'].value) > 3.40214654218 - ( (frame['L4VetoTrackMarginSplitTop'].value - 100)** 1.880562951) / 23709.9897396 else: side = False top = False inside_volume_mono_split = (side and top) # MILLIPEDE WITH OFFLINE PULSES if frame['L4VetoTrackMarginMilliOfflineTop'].value > 100 and frame[ 'L4VetoTrackMarginMilliOfflineSide'].value > 0: side = math.log10(frame['HomogenizedQTot'].value) > 3.40876826865 - ( (frame['L4VetoTrackMarginMilliOfflineSide'].value)** 1.73562251277) / 17266.4002818 top = math.log10(frame['HomogenizedQTot'].value) > 3.40214654218 - ( (frame['L4VetoTrackMarginMilliOfflineTop'].value - 100)** 1.880562951) / 23709.9897396 else: side = False top = False inside_volume_milli_offline = (side and top) if frame["IsCascade_reco"].value == True: if frame["CascadeFilter"].value==True and frame["HomogenizedQTot_split"].value>100. and ((frame["L4VetoTrackOfflineVetoCharge"].value==0 and inside_volume_mono_offline) or (frame["L4VetoTrackOfflineVetoCharge"].value<6 and \ inside_volume_mono_offline and inside_volume_milli_offline)) and \ (numpy.log10(frame["L4MonopodFit"].energy)-numpy.cos(frame["L4MonopodFit"].dir.zenith)>2.2 or \ numpy.cos(frame["L4MonopodFit"].dir.zenith)<0.65): frame["IsCascade"] = icetray.I3Bool(True) frame["IsUpgoingMuon"] = icetray.I3Bool(False) #print "CASCADE (cascade): ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id,frame['HomogenizedQTot'].value#, frame['MuonWeight_GaisserH4a'].value*3600*24*340/160000 return True else: print("Cascade rejected: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id,\ frame["L4VetoTrackOfflineVetoCharge"].value, inside_volume_mono_offline, \ inside_volume_milli_offline, (numpy.log10(frame["L4MonopodFit"].energy)-numpy.cos(frame["L4MonopodFit"].dir.zenith)), numpy.cos(frame["L4MonopodFit"].dir.zenith)) frame["IsCascade"] = icetray.I3Bool(False) else: if (frame["MuonFilter"].value==True and frame["HomogenizedQTot_split"].value>100. and frame["L4VetoTrackMilliOfflineVetoCharge"].value<2 and \ frame["L4VetoTrackOfflineVetoCharge"].value<2 and inside_volume_milli_offline and inside_volume_mono_offline):# or\ #(frame["L4VetoTrackMilliSplitVetoCharge"].value<2 and inside_volume_milli_split): frame["IsCascade"] = icetray.I3Bool(True) frame["IsUpgoingMuon"] = icetray.I3Bool(False) #print "CASCADE (track): ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id,frame['HomogenizedQTot'].value#, frame['MuonWeight_GaisserH4a'].value*3600*24*340/160000 return True else: print("Cascade (tracklike) rejected ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id,\ frame["L4VetoTrackOfflineVetoCharge"].value, inside_volume_mono_offline, \ frame["L4VetoTrackMilliOfflineVetoCharge"].value, inside_volume_milli_offline) frame["IsCascade"] = icetray.I3Bool(False) ########### ## UPMU ########### if ( ( frame['L4UpgoingTrackOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackOfflineVetoCharge'].value > \ frame['L4VetoTrackOfflineVetoCharge'].value and frame['L4UpgoingTrackOfflineVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackSplitVetoCharge'].value > 10 and frame['L4UpgoingTrackSplitVetoCharge'].value > \ frame['L4VetoTrackSplitVetoCharge'].value and frame['L4UpgoingTrackSplitVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > \ frame['L4VetoTrackMilliOfflineVetoCharge'].value and frame['L4UpgoingTrackMilliOfflineVetoChannels'].value > 3 and \ frame['L4UpgoingTrackSplitVetoCharge'].value > 6 ) )\ and frame["TrackFit"].dir.zenith>1.5 and frame["MuonFilter"].value==True:# and frame["OnlineL2Filter"].value==True: frame["IsUpgoingMuon"] = icetray.I3Bool(True) #print "Upgoing Muon event!", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id else: frame["IsUpgoingMuon"] = icetray.I3Bool(False) return frame["IsUpgoingMuon"].value == True or frame[ "IsHese"].value == True or frame["IsCascade"].value == True
def printy(frame): if frame["IsHese"].value == True and frame[ "IsHESE_ck"].value == False and frame[ "CascadeFilter"].value == False: del frame["IsHese"] frame["IsHese"] = icetray.I3Bool(False) if frame["IsCascade"].value == True and frame[ "IsCascade_reco"].value == True and ( frame["L5MonopodFit4"].pos.z < -500 or frame["L5MonopodFit4"].pos.z > 500 or numpy.sqrt(frame["L5MonopodFit4"].pos.x * frame["L5MonopodFit4"].pos.x + frame["L5MonopodFit4"].pos.y * frame["L5MonopodFit4"].pos.y) > 550): print("Cascade event outside of detector... ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) del frame["IsCascade"] frame["IsCascade"] = icetray.I3Bool(False) if frame["IsCascade"].value == True and frame[ "IsCascade_reco"].value == False and ( frame["L4VetoTrackMilliOfflineVetoCharge"].value > 2 or frame['L4VetoTrackMarginMilliOfflineSide'].value < 125): del frame["IsCascade"] frame["IsCascade"] = icetray.I3Bool(False) if frame["IsUpgoingMuon"].value == True: print("UpMu event: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) return True elif frame["IsHese"].value == True: print("HESE event: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) return True elif frame["IsCascade"].value == True and frame[ "L4VetoTrackOfflineVetoCharge"].value < 6 and frame[ "L4VetoTrackL5OfflineVetoCharge"].value < 2: print("Cascade event: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) return True elif frame["IsCascade"].value == True and frame[ "L4VetoTrackOfflineVetoCharge"].value < 2 and frame[ "L4VetoTrackL5OfflineVetoCharge"].value < 3: print("Cascade event: ", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) return True else: if ( ( frame['L4UpgoingTrackOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackOfflineVetoCharge'].value > \ frame['L4VetoTrackOfflineVetoCharge'].value and frame['L4UpgoingTrackOfflineVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackSplitVetoCharge'].value > 10 and frame['L4UpgoingTrackSplitVetoCharge'].value > \ frame['L4VetoTrackSplitVetoCharge'].value and frame['L4UpgoingTrackSplitVetoChannels'].value > 3 ) or \ ( frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > 10 and frame['L4UpgoingTrackMilliOfflineVetoCharge'].value > \ frame['L4VetoTrackMilliOfflineVetoCharge'].value and frame['L4UpgoingTrackMilliOfflineVetoChannels'].value > 3 and \ frame['L4UpgoingTrackSplitVetoCharge'].value > 6 ) )\ and frame["TrackFit"].dir.zenith>1.5 and frame["MuonFilter"].value==True:# and frame["OnlineL2Filter"].value==True: del frame["IsUpgoingMuon"] del frame["IsCascade"] frame["IsUpgoingMuon"] = icetray.I3Bool(True) frame["IsCascade"] = icetray.I3Bool(False) print("UpMu event!", frame["I3EventHeader"].run_id, frame["I3EventHeader"].event_id) return True else: return False
def DAQ(self, frame): frame['DAQyObject'] = icetray.I3Bool(True) self.PushFrame(frame)
def Calibration(self, frame): frame['I3Calibration'] = icetray.I3Bool(True) self.PushFrame(frame)
def DetectorStatus(self, frame): frame['I3DetectorStatus'] = icetray.I3Bool(True) self.PushFrame(frame)
def MarkAndPush(self, frame): frame.Put("DIFF", icetray.I3Bool(True)) self.PushFrame(frame)
def Physics(self, frame): frame['FizzyObject'] = icetray.I3Bool(True) self.PushFrame(frame)
def discriminate(frame): del frame["IsCascade_reco"] del frame["IsTrack_reco"] if frame["IsUpgoingMuon"].value == True: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) return True if ((frame["L4MonopodFit_AvgDistQ"].value - 30) * 0.9 < frame["TrackFit_AvgDistQ"].value): is_track_reco = False is_cascade_reco = True else: is_track_reco = True is_cascade_reco = False if frame["IsCascade"].value == True: if is_track_reco == True: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) elif frame["L4StartingTrackHLCOfflineVetoCharge"].value == 0: frame["IsCascade_reco"] = icetray.I3Bool(True) frame["IsTrack_reco"] = icetray.I3Bool(False) elif frame["L4StartingTrackHLCOfflineVetoCharge"].value > 1.5: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) else: frame["IsCascade_reco"] = icetray.I3Bool(True) frame["IsTrack_reco"] = icetray.I3Bool(False) if frame["IsHese"].value == True: if is_track_reco == True and frame[ "L4StartingTrackHLCMilliOfflineVetoCharge"].value > 50.: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) elif frame["TrackLength"].value > 550 and frame[ "L4StartingTrackHLCOfflineVetoCharge"].value > 30.: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) elif frame["L4StartingTrackHLCOfflineVetoCharge"].value == 0: frame["IsCascade_reco"] = icetray.I3Bool(True) frame["IsTrack_reco"] = icetray.I3Bool(False) elif ( (frame["L4StartingTrackHLCOfflineVetoCharge"].value > 1000. and frame["L4StartingTrackHLCOfflineVetoCharge"].value < 10000.) or (frame["L4StartingTrackHLCMilliOfflineVetoCharge"].value > 1500. and frame["L4StartingTrackHLCOfflineVetoCharge"].value > 200.) ) and frame["L4StartingTrackHLCMilliOfflineVetoCharge"].value > frame[ "L4StartingTrackHLCOfflineVetoCharge"].value: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) elif frame["L4StartingTrackHLCMilliOfflineVetoCharge"].value > 200 and frame[ "L4StartingTrackHLCOfflineVetoCharge"].value > 60 and frame[ "L4StartingTrackHLCMilliOfflineVetoCharge"].value > frame[ "L4StartingTrackHLCOfflineVetoCharge"].value: frame["IsCascade_reco"] = icetray.I3Bool(False) frame["IsTrack_reco"] = icetray.I3Bool(True) #print frame["IsTrack_true"].value, frame["IsTrack_reco"].value, " HESE track (both charges>30)", frame["L4StartingTrackHLCOfflineVetoCharge"].value, frame["L4StartingTrackHLCMilliOfflineVetoCharge"].value else: frame["IsCascade_reco"] = icetray.I3Bool(True) frame["IsTrack_reco"] = icetray.I3Bool(False)