Пример #1
0
    def tracks_run_fill(self, subrun_tgt):
        """
        Clusterize one run
        :param run_number:
        :param data_folder:
        :return:
        """

        if not self.silent:
            print(f"Tracking filling up to subrun {subrun_tgt}")
        tracking_return_list = []
        tracker = pl_lib.tracking_1d(self.run_number, self.data_folder, self.alignment, self.cylinder)
        tracker.load_cluster_1D(self.cylinder)
        path = self.data_folder + f"/raw_root/{self.run_number}/tracks_pd_1D.pickle.gzip"
        if not self.silent:
            print ("Preparing data")
        if os.path.isfile(path):
            data_pd = pd.read_pickle(path, compression="gzip")
            done_subruns = data_pd.subrun.unique()
        else:
            done_subruns = []

        subrun_list = (tracker.read_subruns())
        subruns_to_do = (set(subrun_list) - set(done_subruns))
        subrun_list = [x for x in subruns_to_do if x <= subrun_tgt]


        sub_list=[]
        sub_data = tracker.cluster_pd_1D.groupby("subrun")
        for key in sub_data.groups:
            if key in subrun_list:
                subrun_pd=sub_data.get_group(key)

                if self.cylinder:
                    subrun_pd = subrun_pd.apply(pl_lib.change_planar, 1)
                sub_list.append(subrun_pd)

        del tracker.cluster_pd_1D
        if not self.silent:
            print ("Single view tracking")
        if len(sub_list)>0:
            with Pool(processes=self.cpu_to_use) as pool:
                with tqdm(total=len(sub_list), disable=self.silent) as pbar:
                    for i, x in enumerate(pool.imap_unordered(tracker.build_tracks_pd, sub_list)):
                        tracking_return_list.append(x)
                        pbar.update()
            tracker.tracks_pd=pd.concat(tracking_return_list)
            tracker.append_tracks_pd()
        else:
            print ("No subrun to fit, is the file cluster_pd_1D.pickle.gzip in the working folder? Try to launch with -c")
            return (1)
Пример #2
0
    def select_run(self):
        """
        Build tracks for one run one run
        :param run_number:
        :param data_folder:
        :return:
        """
        tracking_return_list = []

        tracker = pl_lib.tracking_1d(self.run_number, self.data_folder, self.alignment, self.cylinder)
        if not self.silent:
            print("Loading clusters")
        tracker.load_cluster_1D()
        if not self.silent:
            print("Loading tracks")
        tracker.load_tracks_pd()
        sub_list=[]
        tracks_sub_list=[]
        if not self.silent:
            print("Preparing data")
        sub_data = tracker.cluster_pd_1D.groupby("subrun")
        sub_data_tracks = tracker.tracks_pd.groupby("subrun")
        keys_tracker=sub_data_tracks.groups
        for key in sub_data.groups:
            if key in keys_tracker:
                subrun_pd=sub_data.get_group(key)
                if self.cylinder:
                    subrun_pd = subrun_pd.apply(pl_lib.change_planar, 1)
                sub_list.append(subrun_pd)
                tracks_sub_list.append(sub_data_tracks.get_group(key))
        del tracker.cluster_pd_1D
        del tracker.tracks_pd
        input_list=list(zip(sub_list,tracks_sub_list))
        if not self.silent:
            print("Selcting cluster using tracks")
        if len(input_list) > 0:
            with Pool(processes=self.cpu_to_use) as pool:
                with tqdm(total=len(input_list), disable=self.silent) as pbar:
                    for i, x in enumerate(pool.imap_unordered(tracker.build_select_cl_pd, input_list)):
                        tracking_return_list.append(x)
                        pbar.update()
        else:
            print("No track information to select subruns")
            return (1)
        if not self.silent:
            print("Saving")
        tracker.cluster_pd_1D_selected = pd.concat(tracking_return_list, ignore_index=True)
        tracker.save_sel_cl_pd()
Пример #3
0
    def track_subrun(self,subrun):
        """
        Clusterize one run
        :param run_number:
        :param data_folder:
        :return:
        """

        tracker= pl_lib.tracking_1d(self.run_number, self.data_folder, self.alignment, self.cylinder)
        tracker.load_cluster_1D()
        subrun_list=(tracker.read_subruns())

        if subrun in subrun_list:
            tracker.tracks_pd=tracker.build_tracks_pd(subrun)
        else:
            print(f"Can't find subrun {subrun} to track, is the file cluster file in place? try to run with -c")
            return (1)
        tracker.save_tracks_pd(subrun)
Пример #4
0
    def tracks_run(self):
        """
        Build tracks for one run one run
        :param run_number:
        :param data_folder:
        :return:
        """

        tracking_return_list = []
        tracker = pl_lib.tracking_1d(self.run_number, self.data_folder, self.alignment, self.cylinder)
        tracker.load_cluster_1D(self.cylinder)
        if not self.silent:
            print ("Preparing data")

        sub_list=[]
        sub_data = tracker.cluster_pd_1D.groupby("subrun")
        for key in sub_data.groups:
            subrun_pd=sub_data.get_group(key)

            if self.cylinder:
                subrun_pd = subrun_pd.apply(pl_lib.change_planar, 1)
            sub_list.append(subrun_pd)

        del tracker.cluster_pd_1D
        if not self.silent:
            print ("Single view tracking")
        if len(sub_list)>0:
            with Pool(processes=self.cpu_to_use) as pool:
                with tqdm(total=len(sub_list), disable=self.silent) as pbar:
                    for i, x in enumerate(pool.imap_unordered(tracker.build_tracks_pd, sub_list)):
                        tracking_return_list.append(x)
                        pbar.update()
            tracker.tracks_pd=pd.concat(tracking_return_list)
            tracker.save_tracks_pd()
        else:
            print ("No subrun to fit, is the file cluster_pd_1D.pickle.gzip in the working folder? Try to launch with -c")
            return (1)
Пример #5
0
    def select_run_fill(self, subrun_tgt):
        """
        Clusterize one run
        :param run_number:
        :param data_folder:
        :return:
        """
        tracking_return_list = []
        tracker = pl_lib.tracking_1d(self.run_number, self.data_folder, self.alignment, self.cylinder)


        if not self.silent:
            print(f"Selecting clusters near tracks subrun {subrun_tgt}")

        path = self.data_folder + f"/raw_root/{self.run_number}/sel_cluster_pd_1D.pickle.gzip"
        if os.path.isfile(path):
            data_pd = pd.read_pickle(path, compression="gzip")
            done_subruns = data_pd.subrun.unique()
        else:
            done_subruns = []

        subrun_list = (tracker.read_subruns(True))
        subruns_to_do = (set(subrun_list) - set(done_subruns))
        subrun_list = [x for x in subruns_to_do if x <= subrun_tgt]

        if not self.silent:
            print("Loading clusters")
        tracker.load_cluster_1D()
        if not self.silent:
            print("Loading tracks")
        tracker.load_tracks_pd()
        sub_list=[]
        tracks_sub_list=[]
        if not self.silent:
            print("Preparing data")
        sub_data = tracker.cluster_pd_1D.groupby("subrun")
        sub_data_tracks = tracker.tracks_pd.groupby("subrun")
        keys_tracker=sub_data_tracks.groups
        for key in sub_data.groups:
            if key in keys_tracker and key in subrun_list:
                subrun_pd = sub_data.get_group(key)
                if self.cylinder:
                    subrun_pd = subrun_pd.apply(pl_lib.change_planar, 1)
                sub_list.append(subrun_pd)
                tracks_sub_list.append(sub_data_tracks.get_group(key))
        del tracker.cluster_pd_1D
        del tracker.tracks_pd
        input_list = list(zip(sub_list, tracks_sub_list))
        if not self.silent:
            print("Selcting cluster using tracks")
        if len(input_list) > 0:
            with Pool(processes=self.cpu_to_use) as pool:
                with tqdm(total=len(input_list), disable=self.silent) as pbar:
                    for i, x in enumerate(pool.imap_unordered(tracker.build_select_cl_pd, input_list)):
                        tracking_return_list.append(x)
                        pbar.update()
        else:
            print("No track information to select subruns")
            return (1)
        if not self.silent:
            print("Saving")
        tracker.cluster_pd_1D_selected = pd.concat(tracking_return_list, ignore_index=True)
        tracker.append_sel_cl_pd()