From dfe4e6585275816607ae18276ee5b098d3febba8 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Wed, 29 May 2024 17:19:50 +0200 Subject: [PATCH] add pre-commit --- .github/workflows/pre-commit.yml | 23 ++++++++++ .pre-commit-config.yaml | 7 +++ .../Plotting/SuperimposedCanvas.py | 36 +++++++-------- .../Plotting/SuperimposedCanvas_ratio.py | 46 +++++++++---------- .../Plotting/analysis_tracking.py | 10 ++-- .../Plotting/mergeRecOutputs.py | 4 +- .../Plotting/plots_tracking.py | 16 +++---- .../Plotting/plots_tracking_sep.py | 20 ++++---- 8 files changed, 96 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..68a1db8 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,23 @@ +name: pre-commit + +on: [push, pull_request] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cvmfs-contrib/github-action-cvmfs@v3.1 + - uses: aidasoft/run-lcg-view@v4 + with: + release-platform: LCG_101/x86_64-centos7-clang12-opt + run: | + export PYTHONPATH=$(python -m site --user-site):$PYTHONPATH + export PATH=/root/.local/bin:$PATH + pip install --upgrade --user pip + pip install pre-commit --user + # Use virtualenv from the LCG release + pip uninstall --yes virtualenv + pre-commit run --show-diff-on-failure \ + --color=always \ + --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d0f28c1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: mixed-line-ending + - id: trailing-whitespace + - id: end-of-file-fixer diff --git a/TrackingPerformance/Plotting/SuperimposedCanvas.py b/TrackingPerformance/Plotting/SuperimposedCanvas.py index 6486f9c..0456476 100644 --- a/TrackingPerformance/Plotting/SuperimposedCanvas.py +++ b/TrackingPerformance/Plotting/SuperimposedCanvas.py @@ -59,7 +59,7 @@ def combine_canvases(input_files, output_file, marker_styles_func, legend_text, # Define different legend position for theta and momentum plots if marker_styles_func == momentum_styles: output_legend = ROOT.TLegend(0.55, 0.55, 1.30, 0.92) - #output_legend = ROOT.TLegend(0.65, 0.55, 1.30, 0.92) #x1,y1,x2,y2 normalised coordinates in the current pad + #output_legend = ROOT.TLegend(0.65, 0.55, 1.30, 0.92) #x1,y1,x2,y2 normalised coordinates in the current pad elif marker_styles_func == theta_styles: output_legend = ROOT.TLegend(0.5, 0.60, 1.15, 0.92) #x1,y1,x2,y2 normalised coordinates in the current pad output_legend.SetTextFont(62) @@ -72,7 +72,7 @@ def combine_canvases(input_files, output_file, marker_styles_func, legend_text, for input_file_idx, input_file in enumerate(input_files): input_root_file = ROOT.TFile(input_file) input_canvas = input_root_file.Get(canvas_name) - + if input_canvas and input_canvas.InheritsFrom("TCanvas"): primitives = input_canvas.GetListOfPrimitives() for i in range(primitives.GetSize()): @@ -110,15 +110,15 @@ def combine_canvases(input_files, output_file, marker_styles_func, legend_text, if prim.InheritsFrom("TLegend"): input_legend = prim break - + if input_legend: - for marker_idx in range(len(marker_styles)): + for marker_idx in range(len(marker_styles)): new_entry = input_legend.GetListOfPrimitives().At(marker_idx).Clone() new_entry.SetTextFont(43) new_entry.SetFillStyle(0) new_entry.SetMarkerStyle(marker_styles[marker_idx]) new_entry.SetMarkerColor(marker_colors[marker_idx]) - new_entry.SetMarkerSize(1.5) + new_entry.SetMarkerSize(1.5) legend_label = f"{new_entry.GetLabel()}{legend_text[input_file_idx]}\n" output_legend.AddEntry(new_entry, legend_label, "P") #for marker_idx in range(1, len(marker_styles) + 1 ): # Skip legend Title @@ -134,13 +134,13 @@ def combine_canvases(input_files, output_file, marker_styles_func, legend_text, output_canvas = ROOT.TCanvas(canvas_name, "Superposed Canvas", 800, 800) - + # Set log scales for X and Y axes if log_x: output_canvas.SetLogx() if log_y: output_canvas.SetLogy() - + # Get the current pad pad = output_canvas.GetPad(0) # Set the position of the right and top axes @@ -151,17 +151,17 @@ def combine_canvases(input_files, output_file, marker_styles_func, legend_text, output_canvas.SetLeftMargin(0.185) output_canvas.SetTopMargin(0.06) output_canvas.SetBottomMargin(0.15) - + # Draw the superposed TMultiGraph to the output canvas superposed_multigraph.Draw("APE" if output_canvas.GetListOfPrimitives().GetSize() == 0 else "APEsame") - + # Set the X-axis title if marker_styles_func == momentum_styles: superposed_multigraph.GetXaxis().SetTitle("momentum [GeV]") elif marker_styles_func == theta_styles: superposed_multigraph.GetXaxis().SetTitle("#theta [deg]") superposed_multigraph.GetXaxis().SetTitleSize(0.06) - + # Set the Y-axis title based on the input canvas name y_axis_title = set_y_axis_title(canvas_name) superposed_multigraph.GetYaxis().SetTitle(y_axis_title) @@ -174,19 +174,19 @@ def combine_canvases(input_files, output_file, marker_styles_func, legend_text, elif marker_styles_func == momentum_styles: y_axis_range = set_y_axis_range_momentum(canvas_name) superposed_multigraph.GetYaxis().SetRangeUser(y_axis_range[0],y_axis_range[1]) - + # Set bigger axis scale numbers superposed_multigraph.GetXaxis().SetLabelSize(0.05) superposed_multigraph.GetYaxis().SetLabelSize(0.05) - + # Increase the marker size marker_size = 1.5 for graph in superposed_multigraph.GetListOfGraphs(): graph.SetMarkerSize(marker_size) - + # Draw the legend on the output canvas output_legend.Draw() - + # Add text on the top left above the graph text_left_x = 0.19 text_left_y = 0.95 @@ -195,7 +195,7 @@ def combine_canvases(input_files, output_file, marker_styles_func, legend_text, latex_left.SetTextFont(42) latex_left.SetTextSize(0.04) latex_left.DrawLatexNDC(text_left_x, text_left_y, "FCC-ee CLD") - + # Save the output canvas to the root file output_root_file.cd() output_canvas.Write() @@ -210,7 +210,7 @@ def combine_canvases(input_files, output_file, marker_styles_func, legend_text, output_pdf_canvas.Print(output_pdf_file + "]") output_root_file.Close() -if __name__ == "__main__": +if __name__ == "__main__": def set_styles_and_colors_momentum(input_file_idx): marker_styles_full = [ROOT.kFullTriangleUp, ROOT.kFullSquare, ROOT.kFullDiamond, ROOT.kFullCross, ROOT.kFullCircle] @@ -231,7 +231,7 @@ def set_styles_and_colors_momentum(input_file_idx): 0: (marker_styles_full, colors1), 1: (marker_styles_open, colors1), } - + return style_map.get(input_file_idx, (marker_styles_full, colors1)) momentum_styles = set_styles_and_colors_momentum @@ -254,7 +254,7 @@ def set_styles_and_colors_theta(input_file_idx): #2: (marker_styles_full, colors1), #3: (marker_styles_full, colors2), } - + return style_map.get(input_file_idx, (marker_styles_full, colors1)) theta_styles = set_styles_and_colors_theta #_________________________________________________________________ diff --git a/TrackingPerformance/Plotting/SuperimposedCanvas_ratio.py b/TrackingPerformance/Plotting/SuperimposedCanvas_ratio.py index 49535d0..8a32f4c 100644 --- a/TrackingPerformance/Plotting/SuperimposedCanvas_ratio.py +++ b/TrackingPerformance/Plotting/SuperimposedCanvas_ratio.py @@ -98,7 +98,7 @@ def add_entries_from_canvas(input_canvas, styles, colors, output_legend, additio if prim.InheritsFrom("TLegend"): legend = prim break - + if legend: for idx, entry in enumerate(legend.GetListOfPrimitives()): # Skip the first element if necessary @@ -125,7 +125,7 @@ def extract_file_identifier(file_name, canvas_style): else: raise ValueError(f"Unable to extract file identifier from {file_name}") elif canvas_style == 'momentum': - # Processing 'momentum' style + # Processing 'momentum' style if '10.root' in file_name: return '10' elif '30.root' in file_name: @@ -147,7 +147,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ output_pdf_canvas = ROOT.TCanvas("combined_canvas_ratio", "Combined Canvas Ratio", 600, 600) output_pdf_file = output_file_path[:-5] + ".pdf" output_pdf_canvas.Print(output_pdf_file + "[") - + graphs_from_a = {cn: [] for cn in canvas_names} graphs_from_b = {cn: [] for cn in canvas_names} ratio_graphs = {cn: [] for cn in canvas_names} @@ -163,19 +163,19 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ file_path_b = os.path.join(folder_b, file_name) # Calling process_canvas for each file file_identifier_a = extract_file_identifier(file_path_a, canvas_style) - graphs_a = process_canvas(folder_a + file_name, canvas_name, 'a', file_identifier_a, canvas_style) + graphs_a = process_canvas(folder_a + file_name, canvas_name, 'a', file_identifier_a, canvas_style) file_identifier_b = extract_file_identifier(file_path_b, canvas_style) - graphs_b = process_canvas(folder_b + file_name, canvas_name, 'b', file_identifier_b, canvas_style) + graphs_b = process_canvas(folder_b + file_name, canvas_name, 'b', file_identifier_b, canvas_style) # Create a new canvas for comparison and ratio plots output_root_file.cd() comparison_canvas = ROOT.TCanvas(f"{canvas_name}_{file_name[:-5]}", f"Comparison: {canvas_name}", 600, 600) comparison_canvas.Divide(1, 2) # Divide the canvas for original and ratio plots - - # Top pad + + # Top pad pad1 = ROOT.TPad("pad1", "pad1", 0, 0.3, 1, 1.0) - pad1.SetBottomMargin(0.0001) + pad1.SetBottomMargin(0.0001) pad1.SetLeftMargin(0.2) pad1.SetRightMargin(0.02) pad1.SetTopMargin(0.07) @@ -195,7 +195,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ y_axis_title = set_y_axis_title(canvas_name) graph.GetYaxis().SetTitle(y_axis_title) graph.GetXaxis().SetLabelSize(0) - graph.GetYaxis().SetTitleSize(0.08) + graph.GetYaxis().SetTitleSize(0.08) graph.GetYaxis().SetLabelSize(0.07) graph.SetTitle("") pad1.cd() @@ -214,7 +214,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ pad1.cd() graph.Draw("P SAME") # Draw on top of existing graphs without axes graphs_from_b[canvas_name].append(graph) - + pad1.Update() # Log scale for momentum X axis @@ -223,7 +223,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ pad1.Update() - # Bottom pad + # Bottom pad comparison_canvas.cd() # Go back to the canvas to add the second pad pad2 = ROOT.TPad("pad2", "pad2", 0, 0.0, 1, 0.3) @@ -234,7 +234,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ if canvas_style == "momentum": pad2.SetLogx() pad2.Draw() pad2.cd() - + # Calculating and drawing ratio if graphs_a and graphs_b: n_points = graphs_a[0].GetN() @@ -254,7 +254,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ global_min_ratio = ratio if ratio > global_max_ratio: global_max_ratio = ratio - + y_ratio.SetPoint(i, xa, ratio) y_ratio.SetPointError(i, 0, error) file_identifier = extract_file_identifier(folder_b + file_name, canvas_style) @@ -266,13 +266,13 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ y_axis_limits[canvas_name]['min'] = min(y_axis_limits[canvas_name]['min'], ratio) y_axis_limits[canvas_name]['max'] = max(y_axis_limits[canvas_name]['max'], ratio) - y_ratio.GetXaxis().SetTitleSize(0.18) + y_ratio.GetXaxis().SetTitleSize(0.18) y_ratio.GetXaxis().SetLabelSize(0.15) y_ratio.GetXaxis().SetTickSize(0.11) y_ratio.GetYaxis().SetLabelSize(0.08) y_ratio.SetTitle(";#theta [deg];") if canvas_style == "theta" else y_ratio.SetTitle(";momentum [GeV];") y_ratio.Draw("AP") - ratio_graphs[canvas_name].append(y_ratio) + ratio_graphs[canvas_name].append(y_ratio) pad2.SetTicky(1) # Set right axis pad2.Update() @@ -281,7 +281,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ x_max = y_ratio.GetXaxis().GetXmax() # Create a TLine at Y = 1 spanning the width of the x-axis range line = ROOT.TLine(x_min, 1, x_max, 1) - line.SetLineColor(ROOT.kBlack) + line.SetLineColor(ROOT.kBlack) line.SetLineStyle(2) # Set line style to dotted # Draw the line on the same pad as your ratio plot line.Draw("same") @@ -320,7 +320,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ pad1.cd() # Switch to the pad where you want the legend to appear output_legend.Draw() pad1.Update() - + # Add text on the top left above the graph pad1.cd() text_left_x = 0.21 @@ -347,10 +347,10 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ # Top pads top_pad = combined_canvas.cd(1) - top_pad.SetPad(0.0, 0.3, 1.0, 1.0) + top_pad.SetPad(0.0, 0.3, 1.0, 1.0) top_pad.SetRightMargin(0.02) - top_pad.SetTopMargin(0.07) - top_pad.SetBottomMargin(0.0001) + top_pad.SetTopMargin(0.07) + top_pad.SetBottomMargin(0.0001) top_pad.SetLeftMargin(0.2) # Set right and top axes @@ -389,7 +389,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ bottom_pad = combined_canvas.cd(2) bottom_pad.SetPad(0, 0.0, 1, 0.3) - bottom_pad.SetTopMargin(0.0) + bottom_pad.SetTopMargin(0.0) bottom_pad.SetBottomMargin(0.5) # Increase bottom margin for axis labels bottom_pad.SetLeftMargin(0.2) bottom_pad.SetRightMargin(0.02) @@ -401,7 +401,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ draw_option = "APE" if first_graph else "PE same" y_min = y_axis_limits[canvas_name]['min'] y_max = y_axis_limits[canvas_name]['max'] - buffer = (y_max - y_min) * 0.1 + buffer = (y_max - y_min) * 0.1 y_min_adjusted = y_min - buffer y_max_adjusted = y_max + buffer y_ratio.GetYaxis().SetRangeUser(y_min_adjusted, y_max_adjusted) @@ -411,7 +411,7 @@ def process_and_compare_graphs(output_file_path, canvas_names, folder_a, folder_ x_max = y_ratio.GetXaxis().GetXmax() # Create a TLine at Y = 1 spanning the width of the x-axis range line = ROOT.TLine(x_min, 1, x_max, 1) - line.SetLineColor(ROOT.kBlack) + line.SetLineColor(ROOT.kBlack) line.SetLineStyle(2) # Set line style to dotted # Draw the line on the same pad as your ratio plot line.Draw("same") diff --git a/TrackingPerformance/Plotting/analysis_tracking.py b/TrackingPerformance/Plotting/analysis_tracking.py index d6d218a..4ee032f 100644 --- a/TrackingPerformance/Plotting/analysis_tracking.py +++ b/TrackingPerformance/Plotting/analysis_tracking.py @@ -8,7 +8,7 @@ #MomentumList = ["1", "10", "100"] DetectorModel = ["CLD_o2_v05"] # FCCee_o1_v04 CLD_o2_v05 CLD_o3_v01 Nevts = "10000" -Nevts_per_job = "1000" +Nevts_per_job = "1000" # Output and input directories #inputDir = f"/eos/experiment/fcc/users/g/gasadows/TrackingPerformance/{DetectorModel[0]}/REC/mu/VXD_3mic" @@ -56,10 +56,10 @@ def analysers(df): .Define("GunParticle_index", "MCParticles.generatorStatus == 1") .Define("GunParticle", "MCParticles[GunParticle_index][0]") - .Define("trackStates_IP", "SiTracks_Refitted_1[SiTracks_Refitted_1.location == 1]") + .Define("trackStates_IP", "SiTracks_Refitted_1[SiTracks_Refitted_1.location == 1]") .Define("MC2TrackIndex", "MCTruthTrackIndex(MCTrackAssociations0, MCTrackAssociations1, MCParticles)") .Define("GunParticleTrackIndex", "MC2TrackIndex[GunParticle_index][0]") - .Define("GunParticleTSIP", "trackStates_IP[GunParticleTrackIndex]") + .Define("GunParticleTSIP", "trackStates_IP[GunParticleTrackIndex]") .Define("MatchedGunParticle_1", "MCParticles[MC2TrackIndex != -1]") .Define("MatchedGunParticle", "FCCAnalyses::MCParticle::sel_genStatus(1) (MatchedGunParticle_1)") @@ -75,7 +75,7 @@ def analysers(df): .Define("reco_omega", "GunParticleTSIP.omega") .Define("reco_tanLambda", "GunParticleTSIP.tanLambda") .Define("reco_pvec", "auto p = GunParticleTSIPHelix.getMomentum(); return ROOT::Math::XYZVector(p[0], p[1], p[2]);") - .Define("reco_p", "reco_pvec.R()") + .Define("reco_p", "reco_pvec.R()") .Define("reco_phi", "reco_pvec.Phi()") .Define("reco_theta", "reco_pvec.Theta()") @@ -89,7 +89,7 @@ def analysers(df): .Define("true_omega", "GunParticleMCHelix.getOmega()") .Define("true_tanLambda", "GunParticleMCHelix.getTanLambda()") .Define("true_pvec", "ROOT::Math::XYZVector(GunParticleMCMom[0], GunParticleMCMom[1], GunParticleMCMom[2])") - .Define("true_p", "true_pvec.R()") + .Define("true_p", "true_pvec.R()") .Define("true_phi", "true_pvec.Phi()") .Define("true_theta", "true_pvec.Theta()") diff --git a/TrackingPerformance/Plotting/mergeRecOutputs.py b/TrackingPerformance/Plotting/mergeRecOutputs.py index f06eeb5..578f35d 100644 --- a/TrackingPerformance/Plotting/mergeRecOutputs.py +++ b/TrackingPerformance/Plotting/mergeRecOutputs.py @@ -27,14 +27,14 @@ def merge_files(theta, momentum, part, dect, eos_dir, Nevts_, Nevt_per_job): def main(): print(f"Number of processors available: {os.cpu_count()}") - + # Parameters as per your script thetaList_ = ["89"] momentumList_ = ["1", "10", "100"] particleList_ = ["mu"] DetectorModelList_ = ["CLD_o2_v05"] - Nevts_ = "10" + Nevts_ = "10" Nevt_per_job = "5" eos_dir = f"/eos/user/g/gasadows/Output/TrackingPerformance/{DetectorModelList_[0]}/REC/" diff --git a/TrackingPerformance/Plotting/plots_tracking.py b/TrackingPerformance/Plotting/plots_tracking.py index f17e0d7..b4f27c8 100644 --- a/TrackingPerformance/Plotting/plots_tracking.py +++ b/TrackingPerformance/Plotting/plots_tracking.py @@ -5,7 +5,7 @@ ROOT.gStyle.SetOptFit(1111) # Define marker styles and colors marker_styles = [ROOT.kOpenTriangleUp, ROOT.kOpenSquare, ROOT.kOpenDiamond, ROOT.kOpenCross, ROOT.kOpenCircle] -colors = [ROOT.kBlue, ROOT.kRed, ROOT.kMagenta, ROOT.kGreen, ROOT.kBlack] +colors = [ROOT.kBlue, ROOT.kRed, ROOT.kMagenta, ROOT.kGreen, ROOT.kBlack] ROOT.gROOT.SetBatch(True) # Run ROOT in batch mode to avoid displaying the plot canvas_width = 900 # Width of the canvas in pixels canvas_height = 800 # Height of the canvas in pixels @@ -90,7 +90,7 @@ def filter_data_std(data, threshold, n_selections): var_col = {} var_low = {} var_high = {} -h = {} +h = {} # get bin borders and run again to make histograms for p in processList: var_col[p] = {} @@ -100,14 +100,14 @@ def filter_data_std(data, threshold, n_selections): for v in varList: var_col[p][v] = sorted(var_col_rp[p][v].GetValue()) # Adjust the filtering parameters here - threshold = 2.5 # Adjust the threshold value - n_selections = 3 # Adjust the number of selections + threshold = 2.5 # Adjust the threshold value + n_selections = 3 # Adjust the number of selections var_col[p][v] = filter_data_std(var_col[p][v], threshold, n_selections) - + # Recalculate var_low and var_high after filtering var_low[p][v] = min(var_col[p][v]) var_high[p][v] = max(var_col[p][v]) - + h[p][v] = (df[p] .Filter(f"{v} > {var_low[p][v]} && {v} < {var_high[p][v]}") .Histo1D((v, f"{p};{title[v]}", 200, var_low[p][v], var_high[p][v]), v) @@ -215,7 +215,7 @@ def filter_data_std(data, threshold, n_selections): pad.SetTickx(1) # Draw the x-axis ticks on the top pad.SetTicky(1) # Draw the y-axis ticks on the right # Draw the axes and data points - p_dist[v].Draw("APE") + p_dist[v].Draw("APE") # Increase the size of the axis title text p_dist[v].GetXaxis().SetTitleSize(0.06) p_dist[v].GetYaxis().SetTitleSize(0.06) @@ -286,7 +286,7 @@ def filter_data_std(data, threshold, n_selections): pad.SetTickx(1) # Draw the x-axis ticks on the top pad.SetTicky(1) # Draw the y-axis ticks on the right # Draw the axes and data points - t_dist[v].Draw("AP") + t_dist[v].Draw("AP") # Increase the size of the axis title text t_dist[v].GetXaxis().SetTitleSize(0.06) t_dist[v].GetYaxis().SetTitleSize(0.06) diff --git a/TrackingPerformance/Plotting/plots_tracking_sep.py b/TrackingPerformance/Plotting/plots_tracking_sep.py index ef513e8..9a147e0 100644 --- a/TrackingPerformance/Plotting/plots_tracking_sep.py +++ b/TrackingPerformance/Plotting/plots_tracking_sep.py @@ -5,7 +5,7 @@ ROOT.gStyle.SetOptFit(1111) # Define marker styles and colors marker_styles = [ROOT.kOpenTriangleUp, ROOT.kOpenSquare, ROOT.kOpenDiamond, ROOT.kOpenCross, ROOT.kOpenCircle] -colors = [ROOT.kBlue, ROOT.kRed, ROOT.kMagenta, ROOT.kGreen, ROOT.kBlack] +colors = [ROOT.kBlue, ROOT.kRed, ROOT.kMagenta, ROOT.kGreen, ROOT.kBlack] ROOT.gROOT.SetBatch(True) # Run ROOT in batch mode to avoid displaying the plot canvas_width = 900 # Width of the canvas in pixels canvas_height = 800 # Height of the canvas in pixels @@ -94,7 +94,7 @@ def filter_data_std(data, threshold, n_selections): var_col = {} var_low = {} var_high = {} -h = {} +h = {} # get bin borders and run again to make histograms for p in processList: var_col[p] = {} @@ -104,14 +104,14 @@ def filter_data_std(data, threshold, n_selections): for v in varList: var_col[p][v] = sorted(var_col_rp[p][v].GetValue()) # Adjust the filtering parameters here - threshold = 2.5 # Adjust the threshold value - n_selections = 3 # Adjust the number of selections + threshold = 2.5 # Adjust the threshold value + n_selections = 3 # Adjust the number of selections var_col[p][v] = filter_data_std(var_col[p][v], threshold, n_selections) - + # Recalculate var_low and var_high after filtering var_low[p][v] = min(var_col[p][v]) var_high[p][v] = max(var_col[p][v]) - + h[p][v] = (df[p] .Filter(f"{v} > {var_low[p][v]} && {v} < {var_high[p][v]}") .Histo1D((v, f"{p};{title[v]}", 200, var_low[p][v], var_high[p][v]), v) @@ -236,7 +236,7 @@ def filter_data_std(data, threshold, n_selections): pad.SetTickx(1) # Draw the x-axis ticks on the top pad.SetTicky(1) # Draw the y-axis ticks on the right # Draw the axes and data points - p_dist[v].Draw("APE") + p_dist[v].Draw("APE") # Increase the size of the axis title text p_dist[v].GetXaxis().SetTitleSize(0.06) p_dist[v].GetYaxis().SetTitleSize(0.06) @@ -289,7 +289,7 @@ def filter_data_std(data, threshold, n_selections): particle_symbols = {"mu": r"\mu", "pi": r"\pi", "e": r"e"} particle_symbol = particle_symbols.get(particle, particle) legend[v].SetHeader(f"Single {particle_symbol}^{{-}}") - + y = ROOT.std.vector["double"]((sigma[pname(particle, t, p)][v]) for t in ThetaList) x = ROOT.std.vector["double"](float(t) for t in ThetaList) err_y = ROOT.std.vector["double"]((sigma_err[pname(particle, t, p)][v]) for t in ThetaList) @@ -316,7 +316,7 @@ def filter_data_std(data, threshold, n_selections): pad.SetTickx(1) # Draw the x-axis ticks on the top pad.SetTicky(1) # Draw the y-axis ticks on the right # Draw the axes and data points - t_dist[v].Draw("AP") + t_dist[v].Draw("AP") # Increase the size of the axis title text t_dist[v].GetXaxis().SetTitleSize(0.06) t_dist[v].GetYaxis().SetTitleSize(0.06) @@ -334,4 +334,4 @@ def filter_data_std(data, threshold, n_selections): c.Print(f"{fname}]") outfile.Close() -#------------------------------------ \ No newline at end of file +#------------------------------------