def loadFilesWithMask(self): # Use masks? path = "/remote/ceph/group/magic/MAGIC-LST/MARS/CrabNebula/CalibratedWithPointings/2018_03_09/*05070968*00[1-2]*root" mask = self.filepath + self.loadFileName_start + "*" + self.loadFileName_end # Might need to change this line to work? event_factory = MAGICEventSource(input_url=path) event_factory.allowed_tels = self.telescopes # {1, 2} event_generator = event_factory._generator() # event = next(event_generator) for s_event in event_generator: # Use event only if M1 and M2 are triggered # if 1 in s_event.r0.tels_with_data and 1 in self.telescopes and 2 in s_event.r0.tels_with_data: if self.telescopes <= s_event.r0.tels_with_data: self.calibrator.calibrate(s_event) # print("Oder num: {:d}, event id: {:.0f}, triggered telescopes: {}".format(stereo_event.count, stereo_event.r0.event_id, stereo_event.r0.tels_with_data)) a = copy.deepcopy(s_event) self.eventList.append(a) # event_factory.pyhessio.close_file() print("New File loaded, file {:d} contains {:d} events".format( self.currentFileID, len(self.eventList)))
def loadFile(self, path): # Use masks? path = "/remote/ceph/group/magic/MAGIC-LST/MARS/CrabNebula/CalibratedWithPointings/2018_03_09/*05070968*00[1-2]*root" # might need to change this line to work? #try: if True: if self.load_option == LoadOption.raw_sim or self.load_option == LoadOption.raw_data: event_factory = event_source(input_url=path) event_factory.allowed_tels = self.telescopes #{1, 2} event_generator = event_factory._generator() if self.pedestals_only: print( "Warning: Pedestals only available for real data, not for simulation data." ) elif self.load_option == LoadOption.cal_sim or self.load_option == LoadOption.cal_data: #event_factory.allowed_tels = self.telescopes #{1, 2} if self.pedestals_only: event_factory = MAGICEventSource(input_url=path) pedestal_event_generator1 = event_factory._pedestal_event_generator( telescope='M1') pedestal_event_generator2 = event_factory._pedestal_event_generator( telescope='M2') else: event_factory = MAGICEventSource(input_url=path) event_generator = event_factory._generator() else: #except Exception as e: print("Error 194: File does not exist: " + path + " or ") print("Error: %s" % str(e)) return False # event = next(event_generator) if self.pedestals_only: ped_available = True while ped_available: try: p1 = next(pedestal_event_generator1, None) p2 = next(pedestal_event_generator2, None) except: print("Errror:") p1 = None p2 = None if p1 is None or p2 is None: ped_available = False else: a1 = copy.deepcopy(p1) a2 = copy.deepcopy(p2) self.eventList.append({1: a1, 2: a2}) else: for s_event in event_generator: # Use event only if M1 and M2 are triggered #if 1 in s_event.r0.tels_with_data and 1 in self.telescopes and 2 in s_event.r0.tels_with_data: if self.telescopes <= s_event.r0.tels_with_data: if self.calibrate: self.calibrator(s_event) # print("Oder num: {:d}, event id: {:.0f}, triggered telescopes: {}".format(stereo_event.count, stereo_event.r0.event_id, stereo_event.r0.tels_with_data)) a = copy.deepcopy(s_event) if not self.use_cut or apply_cut(a, self.cut_value, self.load_option): self.eventList.append(a) #print("Accepted. ",len(self.eventList)) #event_factory.pyhessio.close_file() print("New File loaded, file {:d} contains {:d} events".format( 14, len(self.eventList))) return True