def process_skim_par(self): print("doing skimming", self.mcordata, self.period) create_folder_struc(self.d_pklsk, self.l_path) arguments = [(i, ) for i in range(len(self.l_reco))] self.parallelizer(self.skim, arguments, self.p_chunksizeskim) if self.p_dofullevtmerge is True: merge_method(self.l_evt, self.f_totevt) merge_method(self.l_evtorig, self.f_totevtorig)
def process_valevents_par(self): print("doing event validation", self.mcordata, self.period) create_folder_struc(self.d_val, self.l_path) tmp_merged = f"/data/tmp/hadd/{self.case}_{self.typean}/val_{self.period}/{get_timestamp_string()}/" arguments = [(i, ) for i in range(len(self.l_evtorig))] self.parallelizer(self.process_valevents, arguments, self.p_chunksizeskim) mergerootfiles(self.l_evtvalroot, self.f_totevtvalroot, tmp_merged)
def plot_jet_lambda(self): # Create directroy to save files pTbins_ranges = get_pT_bin_list(self.pTbins) create_folder_struc(self.j_dir, pTbins_ranges) # Get the list of dataframes containing lambdas info per pT bin, beta, & jet R lambdas_per_bin = self.calc_jet_lambda() # Make plots per jet pT bin print("Plotting jet lambda observable per pT bin") for i, pTmin in list(enumerate(self.pTbins))[0:-1]: pTmax = self.pTbins[i + 1] fig, a = self.initialize_lambda_plots(pTmin, pTmax) # Create subplot per jet R and beta (for each individual pT bin) for j, jetR in enumerate(self.jetRadii): for k, beta in enumerate(self.betas): #lambda_list = lambdas_per_bin[i].at[beta, jetR] binned_lambdas = lambdas_per_bin[i][j][k] ax = a[k, j] ''' old df sln # Normalize histogram by 1/N wg = np.ones(len(lambda_list)) / len(lambda_list) # Approx bin size for good statistics n_bins = 100 #len(lambda_list) // (5 * 10**4) + 1 # Make the subplot a histogram n, bins, patches = ax.hist(lambda_list, range=(0, 0.6), bins=n_bins, weights=wg) ''' wg = sum(binned_lambdas) x = [ (i + 0.5) * self.lambda_max / self.n_lambda_bins for i in range(self.n_lambda_bins) ] ax.bar(x, binned_lambdas/wg, width=(self.lambda_max / self.n_lambda_bins), align='center') #ax.set_ylim(top=max(binned_lambdas/wg)) # Scientific notation on y-axis #ax.ticklabel_format(style='sci', axis='y', scilimits=(0,0)) # Add labels to sub axes ax.set_title(r"$\beta = " + str(beta) + "$, $R = " + str(jetR) + "$, $N = " + str(wg) + '$') ax.set_ylabel(r"$\frac{1}{N}\frac{dN}{d\lambda_\beta}$") ax.set_xlabel(r"$\lambda_\beta$") #if j == 0: # ax.set_ylabel(r"$\beta = " + str(beta) + '$') #if k == (len(self.betas) - 1): # ax.set_xlabel(r"$R = " + str(jetR) + '$') # Save plot plt.subplots_adjust(left = 0.08, right = .97, top = 0.92, bottom = 0.08, wspace = 0.3, hspace = 0.3) out_dir = concat_dir(self.j_dir, pTbins_ranges[i]) fig.savefig('%s/lambda.png' % out_dir) print("Lambda plots successfully saved") return 0
def plot_gen_jet(self): # Create directroy to save files pTbins_ranges = get_pT_bin_list(self.pTbins) create_folder_struc(self.j_dir, pTbins_ranges) # Get the dataframes containing relevant general info N_constit, pT_dist, z_dist = self.calc_gen_jet() # Make general plots print("Plotting general jet distributions") fig_pT, a_pT = self.initialize_gen_plot("Jet pT distribution") fig_N, a_N = self.initialize_gen_plot("Jet constituent multiplicity distribution") fig_z, a_z = self.initialize_gen_plot("Jet z=pT,track/pT,jet distribution") for i, jetR in enumerate(self.jetRadii): ax = a_pT[0, i] pT_list = pT_dist[jetR] n, bins, patches = ax.hist(pT_list) # Scientific notation on y-axis ax.ticklabel_format(style='sci', axis='y', scilimits=(0,0)) # Add labels to sub axes ax.set_title(r"$R = " + str(jetR) + '$') ax.set_ylabel(r"$\frac{dN}{dp_T}$") ax.set_xlabel(r"$p_T$") ax = a_N[0, i] N_list = N_constit[jetR] n, bins, patches = ax.hist(N_list) # Scientific notation on y-axis ax.ticklabel_format(style='sci', axis='y', scilimits=(0,0)) # Add labels to sub axes ax.set_title(r"$R = " + str(jetR) + '$') ax.set_ylabel(r"$\frac{dN}{dN_{constit}}$") ax.set_xlabel(r"$N_{constit}$") ax = a_z[0, i] z_list = z_dist[jetR] n, bins, patches = ax.hist(z_list) # Scientific notation on y-axis ax.ticklabel_format(style='sci', axis='y', scilimits=(0,0)) # Add labels to sub axes ax.set_title(r"$R = " + str(jetR) + '$') ax.set_ylabel(r"$\frac{dN}{dz}$") ax.set_xlabel(r"$z$") # Save plots fig_pT.savefig('%s/pT_dist.png' % self.j_dir) fig_N.savefig('%s/N_dist.png' % self.j_dir) fig_z.savefig('%s/z_dist.png' % self.j_dir) print("General jet plots successfully saved.") return 0
def process_efficiency(self): print("Doing efficiencies", self.mcordata, self.period) print("Using run selection for eff histo", \ self.runlistrigger[self.triggerbit], "for period", self.period) if self.doml is True: print("Doing ml analysis") else: print("No extra selection needed since we are doing std analysis") create_folder_struc(self.d_results, self.l_path) arguments = [(i,) for i in range(len(self.l_root))] self.parallelizer(self.process_efficiency_single, arguments, self.p_chunksizeunp) tmp_merged = f"/data/tmp/hadd/{self.case}_{self.typean}/histoeff_{self.period}/{get_timestamp_string()}/" # pylint: disable=line-too-long mergerootfiles(self.l_histoeff, self.n_fileeff, tmp_merged)
def process_histomass(self): print("Doing masshisto", self.mcordata, self.period) print("Using run selection for mass histo", \ self.runlistrigger, "for period", self.period) if self.doml is True: print("Doing ml analysis") else: print("No extra selection needed since we are doing std analysis") create_folder_struc(self.d_results, self.l_path) arguments = [(i,) for i in range(len(self.l_root))] self.parallelizer(self.process_histomass_single, arguments, self.p_chunksizeunp) tmp_merged = \ f"/data/tmp/hadd/{self.case}_{self.typean}/mass_{self.period}/{get_timestamp_string()}/" mergerootfiles(self.l_histomass, self.n_filemass, tmp_merged)
def process_efficiency(self): print("Doing efficiencies", self.mcordata, self.period) print("Using run selection for eff histo", \ self.runlistrigger, "for period", self.period) if self.doml is True: print("Doing ml analysis") else: print("No extra selection needed since we are doing std analysis") for ibin2 in range(len(self.lvar2_binmin)): if self.corr_eff_mult[ibin2] is True: print("Reweighting efficiencies for bin", ibin2) else: print("Not reweighting efficiencies for bin", ibin2) create_folder_struc(self.d_results, self.l_path) arguments = [(i,) for i in range(len(self.l_root))] self.parallelizer(self.process_efficiency_single, arguments, self.p_chunksizeunp) tmp_merged = f"/data/tmp/hadd/{self.case}_{self.typean}/histoeff_{self.period}/{get_timestamp_string()}/" mergerootfiles(self.l_histoeff, self.n_fileeff, tmp_merged)
def process_applymodel_par(self): print("doing apply model", self.mcordata, self.period) create_folder_struc(self.d_pkl_dec, self.l_path) for ipt in range(self.p_nptbins): arguments = [(i, ) for i in range(len(self.mptfiles_recosk[ipt]))] self.parallelizer(self.applymodel, arguments, self.p_chunksizeskim)
def process_unpack_par(self): print("doing unpacking", self.mcordata, self.period) create_folder_struc(self.d_pkl, self.l_path) arguments = [(i, ) for i in range(len(self.l_root))] self.parallelizer(self.unpack, arguments, self.p_chunksizeunp)
def process_valevents_par(self): print("doing event validation", self.mcordata, self.period) create_folder_struc(self.d_val, self.l_path) arguments = [(i,) for i in range(len(self.l_evtorig))] self.parallelizer(self.process_valevents, arguments, self.p_chunksizeskim) mergerootfiles(self.l_evtvalroot, self.f_totevtvalroot)