From f44270609b974d346d2ef1e5720110a9c353d0ea Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Tue, 18 Jun 2024 10:03:23 +0200 Subject: [PATCH 1/6] Add No TX Fragment Guards. Added a check that a file contains TX fragments before processing. --- scripts/ta_dump.py | 5 +++++ scripts/tc_dump.py | 5 +++++ scripts/tp_dump.py | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/scripts/ta_dump.py b/scripts/ta_dump.py index 6ef80fa..4ec521e 100755 --- a/scripts/ta_dump.py +++ b/scripts/ta_dump.py @@ -290,6 +290,11 @@ def main(): data = trgtools.TAReader(filename, verbosity) + # Check that there are TA fragments. + if len(data.get_fragment_paths()) == 0: + print("File doesn't contain any TriggerActivity fragments.") + return 1 + # Load all case. if start_frag == 0 and end_frag == -1: data.read_all_fragments() # Has extra debug/warning info diff --git a/scripts/tc_dump.py b/scripts/tc_dump.py index d57fa90..19968a7 100755 --- a/scripts/tc_dump.py +++ b/scripts/tc_dump.py @@ -283,6 +283,11 @@ def main(): data = trgtools.TCReader(filename, verbosity) + # Check that there are TC fragments. + if len(data.get_fragment_paths()) == 0: + print("File doesn't contain any TriggerCandidate fragments.") + return 1 + # Load all case. if start_frag == 0 and end_frag == -1: data.read_all_fragments() # Has extra debug/warning info diff --git a/scripts/tp_dump.py b/scripts/tp_dump.py index ab0c81a..ad04baf 100755 --- a/scripts/tp_dump.py +++ b/scripts/tp_dump.py @@ -248,6 +248,11 @@ def main(): data = trgtools.TPReader(filename, verbosity) + # Check that there are TP fragments. + if len(data.get_fragment_paths()) == 0: + print("File doesn't contain any TriggerPrimitive fragments.") + return 1 + # Load all case if start_frag == 0 and end_frag == -1: data.read_all_fragments() # Has extra debug/warning info From 608ac2a08b53c994179f5a14d014550e41a672f9 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Tue, 18 Jun 2024 15:49:12 +0200 Subject: [PATCH 2/6] Add Alg/Type Histogram Fontsize. Added a fontsize for the awkward, long names in the alg/type histograms. --- scripts/ta_dump.py | 2 ++ scripts/tc_dump.py | 2 ++ scripts/tp_dump.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/scripts/ta_dump.py b/scripts/ta_dump.py index 4ec521e..e01f79a 100755 --- a/scripts/ta_dump.py +++ b/scripts/ta_dump.py @@ -354,6 +354,7 @@ def main(): 'xticks': { 'labels': ALGORITHM_LABELS, 'ticks': ALGORITHM_TICKS, + 'fontsize': 6, 'rotation': 60, 'ha': 'right' # Horizontal alignment } @@ -454,6 +455,7 @@ def main(): 'xticks': { 'labels': TYPE_LABELS, 'ticks': TYPE_TICKS, + 'fontsize': 6, 'rotation': 60, 'ha': 'right' # Horizontal alignment } diff --git a/scripts/tc_dump.py b/scripts/tc_dump.py index 19968a7..39e1f16 100755 --- a/scripts/tc_dump.py +++ b/scripts/tc_dump.py @@ -330,6 +330,7 @@ def main(): 'xticks': { 'labels': ALGORITHM_LABELS, 'ticks': ALGORITHM_TICKS, + 'fontsize': 6, 'rotation': 60, 'ha': 'right' # Horizontal alignment } @@ -399,6 +400,7 @@ def main(): 'xticks': { 'labels': TYPE_LABELS, 'ticks': TYPE_TICKS, + 'fontsize': 6, 'rotation': 60, 'ha': 'right' # Horizontal alignment } diff --git a/scripts/tp_dump.py b/scripts/tp_dump.py index ad04baf..217a56d 100755 --- a/scripts/tp_dump.py +++ b/scripts/tp_dump.py @@ -313,6 +313,7 @@ def main(): 'xticks': { 'labels': ALGORITHM_LABELS, 'ticks': ALGORITHM_TICKS, + 'fontsize': 6, 'rotation': 60, 'ha': 'right' # Horizontal alignment } @@ -386,6 +387,7 @@ def main(): 'xticks': { 'labels': TYPE_LABELS, 'ticks': TYPE_TICKS, + 'fontsize': 6, 'rotation': 60, 'ha': 'right' # Horizontal alignment } From bd35e2111ab4fb7054bfbd19015dcea14b635c95 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Tue, 18 Jun 2024 16:18:41 +0200 Subject: [PATCH 3/6] Squash Alg/Type Histogram Bins. Made alg/type histogram bins slightly smaller for there to be a gap. --- scripts/ta_dump.py | 4 ++-- scripts/tc_dump.py | 4 ++-- scripts/tp_dump.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/ta_dump.py b/scripts/ta_dump.py index e01f79a..41dc357 100755 --- a/scripts/ta_dump.py +++ b/scripts/ta_dump.py @@ -344,7 +344,7 @@ def main(): 'log_style': dict(color='#EE442F', alpha=0.6, label='Log') }, 'algorithm': { - 'bins': np.arange(-0.5, np.max(ALGORITHM_TICKS) + 1, 1), + 'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in ALGORITHM_TICKS]).flatten()), 'title': "Algorithm Histogram", 'xlabel': 'Algorithm Type', 'ylabel': "Count", @@ -445,7 +445,7 @@ def main(): 'log_style': dict(color='#EE442F', alpha=0.6, label='Log') }, 'type': { - 'bins': np.arange(-0.5, np.max(TYPE_TICKS) + 1, 1), + 'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in TYPE_TICKS]).flatten()), 'title': "Type Histogram", 'xlabel': "Type", 'ylabel': "Count", diff --git a/scripts/tc_dump.py b/scripts/tc_dump.py index 39e1f16..4a0dcf0 100755 --- a/scripts/tc_dump.py +++ b/scripts/tc_dump.py @@ -320,7 +320,7 @@ def main(): # Dictionary containing unique title, xlabel, and xticks (only some) plot_hist_dict = { 'algorithm': { - 'bins': np.arange(-0.5, np.max(ALGORITHM_TICKS) + 1, 1), + 'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in ALGORITHM_TICKS]).flatten()), 'title': "Algorithm", 'xlabel': 'Algorithm Type', 'ylabel': "Count", @@ -390,7 +390,7 @@ def main(): 'log_style': dict(color='#EE442F', alpha=0.6, label='Log') }, 'type': { - 'bins': np.arange(-0.5, np.max(TYPE_TICKS) + 1, 1), + 'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in TYPE_TICKS]).flatten()), 'title': "Type", 'xlabel': "Type", 'ylabel': "Count", diff --git a/scripts/tp_dump.py b/scripts/tp_dump.py index 217a56d..2e9584f 100755 --- a/scripts/tp_dump.py +++ b/scripts/tp_dump.py @@ -303,7 +303,7 @@ def main(): 'log_style': dict(color='#EE442F', alpha=0.6, label='Log') }, 'algorithm': { - 'bins': np.arange(-0.5, np.max(ALGORITHM_TICKS) + 1, 1), + 'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in ALGORITHM_TICKS]).flatten()), 'title': "Algorithm Histogram", 'xlabel': 'Algorithm Type', 'ylabel': "Count", @@ -377,7 +377,7 @@ def main(): 'log_style': dict(color='#EE442F', alpha=0.6, label='Log') }, 'type': { - 'bins': np.arange(-0.5, np.max(TYPE_TICKS) + 1, 1), + 'bins': np.sort(np.array([(tick-0.45, tick+0.45) for tick in TYPE_TICKS]).flatten()), 'title': "Type Histogram", 'xlabel': "Type", 'ylabel': "Count", From 0b18bf1ab268ce18e72306d6ab6f86b6923d61c0 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Fri, 28 Jun 2024 08:09:12 +0200 Subject: [PATCH 4/6] Add Color To Hist Axes. Added linear and log colors to the corresponding axes. --- python/trgtools/plot/PDFPlotter.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python/trgtools/plot/PDFPlotter.py b/python/trgtools/plot/PDFPlotter.py index c351124..f6d2074 100644 --- a/python/trgtools/plot/PDFPlotter.py +++ b/python/trgtools/plot/PDFPlotter.py @@ -130,6 +130,17 @@ def plot_histogram( ax.patch.set_visible(False) ax2.set_zorder(1) + linear_color = plot_details_dict.get('linear_style', self._DEFAULT_HIST_STYLE).get('color', self._DEFAULT_HIST_STYLE['linear_style']['color']) + # Set axis and tick colors. + ax.spines['left'].set_color(linear_color) + ax.yaxis.label.set_color(linear_color) + ax.tick_params('y', colors=linear_color) + + log_color = plot_details_dict.get('log_style', self._DEFAULT_HIST_STYLE).get('color', self._DEFAULT_HIST_STYLE['log_style']['color']) + ax.spines['right'].set_color(log_color) # Actually belongs to ax and not ax2. + ax2.yaxis.label.set_color(log_color) + ax2.tick_params('y', colors=log_color) + handles, labels = ax.get_legend_handles_labels() handles2, labels2 = ax2.get_legend_handles_labels() handles = handles + handles2 From 4c5f301031513df237f699c0f6a7cdccad9cea80 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Fri, 28 Jun 2024 09:04:53 +0200 Subject: [PATCH 5/6] Add Unity And Transparency. Added the unity line and made markers transparent. --- scripts/tp_dump.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/tp_dump.py b/scripts/tp_dump.py index 2e9584f..ba96e30 100755 --- a/scripts/tp_dump.py +++ b/scripts/tp_dump.py @@ -100,15 +100,20 @@ def plot_pdf_adc_integral_vs_peak(tp_data: np.ndarray, pdf: PdfPages, verbosity: ) print("Total number of TPs:", len(tp_data['adc_peak'])) high_integral_locs = np.where(tp_data['adc_integral'] == np.power(2, 15)-1) + unity = (np.min(tp_data['adc_peak']), np.max(tp_data['adc_peak'])) plt.figure(figsize=(6, 4), dpi=200) - plt.scatter( + plt.plot( tp_data['adc_peak'], tp_data['adc_integral'], - c='k', - s=2, + c="#00000055", + ms=2, + ls='none', + marker='o', + mew=0, label='TP', + zorder=2, rasterized=True ) plt.scatter( @@ -117,8 +122,17 @@ def plot_pdf_adc_integral_vs_peak(tp_data: np.ndarray, pdf: PdfPages, verbosity: c='#63ACBE', s=2, marker='+', label=r'$2^{15}-1$', + zorder=3, rasterized=True ) + plt.plot( + unity, + unity, + color='#EE442F', + label="Unity", + lw=2, + zorder=1 + ) plt.title("ADC Integral vs ADC Peak") plt.xlabel("ADC Peak") From 8a2cfa3686d1855591a7949ad4834ce699a8c3a1 Mon Sep 17 00:00:00 2001 From: Alejandro Oranday Date: Mon, 1 Jul 2024 11:39:01 +0200 Subject: [PATCH 6/6] Correct Help Descriptions --- scripts/ta_dump.py | 2 +- scripts/tc_dump.py | 2 +- scripts/tp_dump.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ta_dump.py b/scripts/ta_dump.py index 41dc357..63cbebe 100755 --- a/scripts/ta_dump.py +++ b/scripts/ta_dump.py @@ -206,7 +206,7 @@ def parse(): Parses CLI input arguments. """ parser = argparse.ArgumentParser( - description="Display diagnostic information for TAs for a given tpstream file." + description="Display diagnostic information for TAs for a given HDF5 file." ) parser.add_argument( "filename", diff --git a/scripts/tc_dump.py b/scripts/tc_dump.py index 4a0dcf0..ca9cae0 100755 --- a/scripts/tc_dump.py +++ b/scripts/tc_dump.py @@ -205,7 +205,7 @@ def parse(): Parses CLI input arguments. """ parser = argparse.ArgumentParser( - description="Display diagnostic information for TCs for a given tpstream file." + description="Display diagnostic information for TCs for a given HDF5 file." ) parser.add_argument( "filename", diff --git a/scripts/tp_dump.py b/scripts/tp_dump.py index ba96e30..b4aac13 100755 --- a/scripts/tp_dump.py +++ b/scripts/tp_dump.py @@ -184,7 +184,7 @@ def write_summary_stats(data: np.ndarray, filename: str, title: str) -> None: def parse(): parser = argparse.ArgumentParser( - description="Display diagnostic information for TAs for a given tpstream file." + description="Display diagnostic information for TPs for a given HDF5 file." ) parser.add_argument( "filename",