From 2fc3fe8b51c2863727b1f3968b75d8d0fff54663 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Mon, 1 Jun 2026 20:29:43 +0200 Subject: [PATCH 01/23] readme fix --- release_tests/sources/Crab/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_tests/sources/Crab/README.md b/release_tests/sources/Crab/README.md index 34f56af..b1c9330 100644 --- a/release_tests/sources/Crab/README.md +++ b/release_tests/sources/Crab/README.md @@ -43,7 +43,7 @@ for Combine files using pre-processed anasum files and run list generated in step before: ```bash -./anasum_yearly.sh +./anasum_from_runlists.sh ``` ## Plotting From cf58d59dbef8c7a3ddba73ced0cd7b3ec7ddaf9a Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Mon, 1 Jun 2026 20:35:32 +0200 Subject: [PATCH 02/23] add warning --- release_tests/montecarlo/irf_plotting/irf_plotting.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/release_tests/montecarlo/irf_plotting/irf_plotting.sh b/release_tests/montecarlo/irf_plotting/irf_plotting.sh index 02ddf03..7a41c35 100755 --- a/release_tests/montecarlo/irf_plotting/irf_plotting.sh +++ b/release_tests/montecarlo/irf_plotting/irf_plotting.sh @@ -18,6 +18,7 @@ CUT="NTel3-PointSource-Hard-TMVA-BDT" CUT="NTel2-PointSource-Soft-TMVA-BDT" CUT="NTel2-PointSource-Moderate-TMVA-BDT" CUT="NTel2-PointSource-Moderate" +echo "WARNING: CUT is hardwired to $CUT (for now)" # Comparison plots - version and simtype hardwired COMPAREVERSION="v492" COMPARESIMTYPE="CARE_202404" From b1c5b95646eab53afe5b7173fae67a61df976131 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Tue, 2 Jun 2026 10:01:08 +0200 Subject: [PATCH 03/23] R__LOAD --- release_tests/utilities/parameters.C | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/release_tests/utilities/parameters.C b/release_tests/utilities/parameters.C index a6880a8..cf49eeb 100644 --- a/release_tests/utilities/parameters.C +++ b/release_tests/utilities/parameters.C @@ -17,8 +17,9 @@ * Helper for ROOT macros: load libVAnaSum from environment. * Search order: * 1) $VERITAS_VANASUM_LIBRARY - * 2) $EVNDISP/lib/libVAnaSum.so - * 3) ROOT library path via "libVAnaSum.so" + * 2) $EVNDISPSYS/lib/libVAnaSum.so + * 3) $EVNDISP/lib/libVAnaSum.so + * 4) ROOT library path via "libVAnaSum.so" */ bool loadVAnaSumLibrary() { @@ -35,6 +36,14 @@ bool loadVAnaSumLibrary() iLibPath = iEnvLib; } if( iLibPath.size() == 0 ) + { + const char* iEvndispSys = gSystem->Getenv( "EVNDISPSYS" ); + if( iEvndispSys ) + { + iLibPath = string( iEvndispSys ) + "/lib/libVAnaSum.so"; + } + } + if( iLibPath.size() == 0 ) { const char* iEvndisp = gSystem->Getenv( "EVNDISP" ); if( iEvndisp ) @@ -45,21 +54,26 @@ bool loadVAnaSumLibrary() if( iLibPath.size() > 0 && !gSystem->AccessPathName( iLibPath.c_str() ) ) { - if( gSystem->Load( iLibPath.c_str() ) >= 0 ) + // Use gROOT->ProcessLine to properly load the library and its dictionaries + string loadCmd = "R__LOAD_LIBRARY(" + iLibPath + ");"; + int result = gROOT->ProcessLine( loadCmd.c_str() ); + if( result >= 0 ) { iLibraryLoaded = true; return true; } } - if( gSystem->Load( "libVAnaSum.so" ) >= 0 ) + // Try with just the library name + int result = gROOT->ProcessLine( "R__LOAD_LIBRARY(libVAnaSum.so);" ); + if( result >= 0 ) { iLibraryLoaded = true; return true; } cout << "Error: unable to load libVAnaSum.so. " - << "Set VERITAS_VANASUM_LIBRARY or EVNDISP." << endl; + << "Set VERITAS_VANASUM_LIBRARY, EVNDISPSYS, or EVNDISP." << endl; return false; } From 9598b166938bb20395d055eff1e2f5b3bfaae5d7 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Tue, 2 Jun 2026 15:01:54 +0200 Subject: [PATCH 04/23] debugging --- release_tests/utilities/parameters.C | 36 ++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/release_tests/utilities/parameters.C b/release_tests/utilities/parameters.C index cf49eeb..af8db58 100644 --- a/release_tests/utilities/parameters.C +++ b/release_tests/utilities/parameters.C @@ -34,6 +34,7 @@ bool loadVAnaSumLibrary() if( iEnvLib ) { iLibPath = iEnvLib; + cout << "DEBUG: Found VERITAS_VANASUM_LIBRARY=" << iLibPath << endl; } if( iLibPath.size() == 0 ) { @@ -41,6 +42,7 @@ bool loadVAnaSumLibrary() if( iEvndispSys ) { iLibPath = string( iEvndispSys ) + "/lib/libVAnaSum.so"; + cout << "DEBUG: Using EVNDISPSYS, iLibPath=" << iLibPath << endl; } } if( iLibPath.size() == 0 ) @@ -49,26 +51,46 @@ bool loadVAnaSumLibrary() if( iEvndisp ) { iLibPath = string( iEvndisp ) + "/lib/libVAnaSum.so"; + cout << "DEBUG: Using EVNDISP, iLibPath=" << iLibPath << endl; } } - if( iLibPath.size() > 0 && !gSystem->AccessPathName( iLibPath.c_str() ) ) + if( iLibPath.size() > 0 ) { - // Use gROOT->ProcessLine to properly load the library and its dictionaries - string loadCmd = "R__LOAD_LIBRARY(" + iLibPath + ");"; - int result = gROOT->ProcessLine( loadCmd.c_str() ); - if( result >= 0 ) + cout << "DEBUG: Checking if library exists: " << iLibPath << endl; + if( !gSystem->AccessPathName( iLibPath.c_str() ) ) { - iLibraryLoaded = true; - return true; + cout << "DEBUG: Library file exists, attempting to load with R__LOAD_LIBRARY" << endl; + // Use gROOT->ProcessLine to properly load the library and its dictionaries + string loadCmd = "R__LOAD_LIBRARY(" + iLibPath + ");"; + cout << "DEBUG: Executing: " << loadCmd << endl; + int result = gROOT->ProcessLine( loadCmd.c_str() ); + cout << "DEBUG: ProcessLine result: " << result << endl; + if( result >= 0 ) + { + iLibraryLoaded = true; + cout << "DEBUG: Successfully loaded library from " << iLibPath << endl; + return true; + } } + else + { + cout << "DEBUG: Library file does NOT exist: " << iLibPath << endl; + } + } + else + { + cout << "DEBUG: No library path determined from environment variables" << endl; } // Try with just the library name + cout << "DEBUG: Trying to load libVAnaSum.so from ROOT library path" << endl; int result = gROOT->ProcessLine( "R__LOAD_LIBRARY(libVAnaSum.so);" ); + cout << "DEBUG: ProcessLine result for libVAnaSum.so: " << result << endl; if( result >= 0 ) { iLibraryLoaded = true; + cout << "DEBUG: Successfully loaded libVAnaSum.so from ROOT library path" << endl; return true; } From 18f3b486223805bf4f764e1d46a66ea585ec0ecd Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Tue, 2 Jun 2026 15:25:13 +0200 Subject: [PATCH 05/23] library path --- .../sources/Crab/plot_energy_spectra.C | 4 +++ release_tests/utilities/parameters.C | 36 ++++--------------- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/release_tests/sources/Crab/plot_energy_spectra.C b/release_tests/sources/Crab/plot_energy_spectra.C index 3fc3e6d..8ab721c 100644 --- a/release_tests/sources/Crab/plot_energy_spectra.C +++ b/release_tests/sources/Crab/plot_energy_spectra.C @@ -14,6 +14,10 @@ #include "TF1.h" +// Load VAnaSum library - must be before any usage of VEnergySpectrum +// ROOT expands environment variables in R__LOAD_LIBRARY paths +R__LOAD_LIBRARY($EVNDISPSYS/lib/libVAnaSum.so) + #include "../../utilities/parameters.C" #include "../../utilities/printutilities.C" diff --git a/release_tests/utilities/parameters.C b/release_tests/utilities/parameters.C index af8db58..cf49eeb 100644 --- a/release_tests/utilities/parameters.C +++ b/release_tests/utilities/parameters.C @@ -34,7 +34,6 @@ bool loadVAnaSumLibrary() if( iEnvLib ) { iLibPath = iEnvLib; - cout << "DEBUG: Found VERITAS_VANASUM_LIBRARY=" << iLibPath << endl; } if( iLibPath.size() == 0 ) { @@ -42,7 +41,6 @@ bool loadVAnaSumLibrary() if( iEvndispSys ) { iLibPath = string( iEvndispSys ) + "/lib/libVAnaSum.so"; - cout << "DEBUG: Using EVNDISPSYS, iLibPath=" << iLibPath << endl; } } if( iLibPath.size() == 0 ) @@ -51,46 +49,26 @@ bool loadVAnaSumLibrary() if( iEvndisp ) { iLibPath = string( iEvndisp ) + "/lib/libVAnaSum.so"; - cout << "DEBUG: Using EVNDISP, iLibPath=" << iLibPath << endl; } } - if( iLibPath.size() > 0 ) + if( iLibPath.size() > 0 && !gSystem->AccessPathName( iLibPath.c_str() ) ) { - cout << "DEBUG: Checking if library exists: " << iLibPath << endl; - if( !gSystem->AccessPathName( iLibPath.c_str() ) ) + // Use gROOT->ProcessLine to properly load the library and its dictionaries + string loadCmd = "R__LOAD_LIBRARY(" + iLibPath + ");"; + int result = gROOT->ProcessLine( loadCmd.c_str() ); + if( result >= 0 ) { - cout << "DEBUG: Library file exists, attempting to load with R__LOAD_LIBRARY" << endl; - // Use gROOT->ProcessLine to properly load the library and its dictionaries - string loadCmd = "R__LOAD_LIBRARY(" + iLibPath + ");"; - cout << "DEBUG: Executing: " << loadCmd << endl; - int result = gROOT->ProcessLine( loadCmd.c_str() ); - cout << "DEBUG: ProcessLine result: " << result << endl; - if( result >= 0 ) - { - iLibraryLoaded = true; - cout << "DEBUG: Successfully loaded library from " << iLibPath << endl; - return true; - } + iLibraryLoaded = true; + return true; } - else - { - cout << "DEBUG: Library file does NOT exist: " << iLibPath << endl; - } - } - else - { - cout << "DEBUG: No library path determined from environment variables" << endl; } // Try with just the library name - cout << "DEBUG: Trying to load libVAnaSum.so from ROOT library path" << endl; int result = gROOT->ProcessLine( "R__LOAD_LIBRARY(libVAnaSum.so);" ); - cout << "DEBUG: ProcessLine result for libVAnaSum.so: " << result << endl; if( result >= 0 ) { iLibraryLoaded = true; - cout << "DEBUG: Successfully loaded libVAnaSum.so from ROOT library path" << endl; return true; } From e576709dccfd68a329cff5f26c2b4caf67d8a074 Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Tue, 2 Jun 2026 15:39:49 +0200 Subject: [PATCH 06/23] setting of library path --- release_tests/sources/Crab/plot_energy_spectra.C | 2 -- release_tests/sources/Crab/plot_lightcurves.C | 2 ++ release_tests/sources/Crab/plot_sensitivity.C | 1 + release_tests/sources/Crab/plot_skymaps.C | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/release_tests/sources/Crab/plot_energy_spectra.C b/release_tests/sources/Crab/plot_energy_spectra.C index 8ab721c..882d484 100644 --- a/release_tests/sources/Crab/plot_energy_spectra.C +++ b/release_tests/sources/Crab/plot_energy_spectra.C @@ -14,8 +14,6 @@ #include "TF1.h" -// Load VAnaSum library - must be before any usage of VEnergySpectrum -// ROOT expands environment variables in R__LOAD_LIBRARY paths R__LOAD_LIBRARY($EVNDISPSYS/lib/libVAnaSum.so) #include "../../utilities/parameters.C" diff --git a/release_tests/sources/Crab/plot_lightcurves.C b/release_tests/sources/Crab/plot_lightcurves.C index 458f068..5b341a7 100644 --- a/release_tests/sources/Crab/plot_lightcurves.C +++ b/release_tests/sources/Crab/plot_lightcurves.C @@ -13,6 +13,8 @@ #include #include +R__LOAD_LIBRARY($EVNDISPSYS/lib/libVAnaSum.so) + #include "../../utilities/parameters.C" #include "../../utilities/printutilities.C" diff --git a/release_tests/sources/Crab/plot_sensitivity.C b/release_tests/sources/Crab/plot_sensitivity.C index b8c4fd8..84de9dd 100644 --- a/release_tests/sources/Crab/plot_sensitivity.C +++ b/release_tests/sources/Crab/plot_sensitivity.C @@ -4,6 +4,7 @@ */ #include +R__LOAD_LIBRARY($EVNDISPSYS/lib/libVAnaSum.so) #include "../../utilities/parameters.C" #include "../../utilities/printutilities.C" diff --git a/release_tests/sources/Crab/plot_skymaps.C b/release_tests/sources/Crab/plot_skymaps.C index 98d905a..5c8fda3 100644 --- a/release_tests/sources/Crab/plot_skymaps.C +++ b/release_tests/sources/Crab/plot_skymaps.C @@ -11,6 +11,8 @@ #include #include +R__LOAD_LIBRARY($EVNDISPSYS/lib/libVAnaSum.so) + #include "../../utilities/parameters.C" #include "../../utilities/printutilities.C" From c89dd6c47dea47cc3354dd36974fa7a954d48514 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Thu, 4 Jun 2026 15:00:41 +0200 Subject: [PATCH 07/23] Add plotting of sensitivtiy from log files --- .../Crab/plot_sensitivity_from_anasum_log.py | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 release_tests/sources/Crab/plot_sensitivity_from_anasum_log.py diff --git a/release_tests/sources/Crab/plot_sensitivity_from_anasum_log.py b/release_tests/sources/Crab/plot_sensitivity_from_anasum_log.py new file mode 100644 index 0000000..772eddd --- /dev/null +++ b/release_tests/sources/Crab/plot_sensitivity_from_anasum_log.py @@ -0,0 +1,184 @@ +"""Plot sensitivity diagnostics from anasum log files. + +Reads anasum log files from an input directory and writes a PNG summary figure. + +Usage: python plot_sensitivity_from_anasum_log.py [input_dir] [output_png] +""" + +import argparse +import glob +import os +import re + +import matplotlib.pyplot as plt +import numpy as np + +# Parse input directory argument +parser = argparse.ArgumentParser(description="Plot sensitivity metrics from anasum log files.") +parser.add_argument( + "input_dir", + nargs="?", + default=".", + help="Directory containing anasum log files (default: current directory)", +) +parser.add_argument( + "output_png", + nargs="?", + default="anasum_analysis_plots.png", + help="Output PNG filename (default: anasum_analysis_plots.png)", +) +args = parser.parse_args() + +if not os.path.isdir(args.input_dir): + raise SystemExit(f"Input directory does not exist: {args.input_dir}") + +log_files = sorted(glob.glob(os.path.join(args.input_dir, "*anasum*.log"))) + +if not log_files: + raise SystemExit(f"No anasum log files found in: {args.input_dir}") + +epochs = [] +on_off_summary_rates = [] +off_summary_rates = [] +crab_001_times = [] +all_elevations = [] +all_on_rates = [] +all_off_rates = [] + +for filepath in log_files: + with open(filepath, "r") as f: + content = f.read() + + # Extract epoch from filename (e.g., V6_2023_2023s_ATM62 or V6_2014_2015_ATM61) + basename = os.path.basename(filepath) + epoch_match = re.search(r"(V6_[^_]+_\d+[a-z]*)_ATM\d+", basename) + if not epoch_match: + # Try alternative pattern for ATM61 files + epoch_match = re.search( + r"(V6_[^_]+_\d+[a-z]*)_ATM\d+", basename.replace("_SZE_0.5deg.combined", "") + ) + if not epoch_match: + continue + epoch = epoch_match.group(1) + + # Extract summary on/off rates + rate_match = re.search(r"Rates \(on/Off\): (\d+\.\d+)\s+(\d+\.\d+)", content) + + # Extract 0.01 Crab time in hours from the sensitivity table + lines = content.split("\n") + crab_time = None + in_table = False + for line in lines: + if "[h]" in line: + in_table = True + continue + if in_table and line.strip().startswith("0.01"): + parts = line.split() + if len(parts) >= 3: + try: + crab_time = float(parts[-1]) + except ValueError: + pass + break + + # Extract all elevation and rate values from RUN lines + el_values = [] + on_rates = [] + off_rates = [] + for line in lines: + el_match = re.search(r"RUN\s+\d+.*at\s+(\d+),\s+(-?\d+)\s+deg\s+El\.,\s+Az", line) + rate_match_line = re.search(r"Rates:\s+([\d.]+).*background:\s+([\d.]+)", line) + if el_match: + el_values.append(int(el_match.group(1))) + if rate_match_line: + on_rates.append(float(rate_match_line.group(1))) + off_rates.append(float(rate_match_line.group(2))) + + # Only add data if we have all values and non-empty arrays + if rate_match and crab_time is not None and el_values and on_rates and off_rates: + epochs.append(epoch) + on_off_summary_rates.append(float(rate_match.group(1))) + off_summary_rates.append(float(rate_match.group(2))) + crab_001_times.append(crab_time) + all_elevations.append(np.array(el_values)) + all_on_rates.append(np.array(on_rates)) + all_off_rates.append(np.array(off_rates)) + +# Calculate average elevation per epoch for sensitivity plot +avg_elevations = [np.mean(el) for el in all_elevations] + +# Create plots - 4 rows: 2x2 + 2 extra +fig, axs = plt.subplots(4, 2, figsize=(14, 20)) + +# Plot 1: On Rate vs Epoch +axs[0, 0].plot(epochs, on_off_summary_rates, "o-", color="blue") +axs[0, 0].set_xlabel("Epoch") +axs[0, 0].set_ylabel("On Rate") +axs[0, 0].set_title("On Rate vs Epoch") +axs[0, 0].tick_params(axis="x", rotation=45) + +# Plot 2: Off Rate vs Epoch +axs[0, 1].plot(epochs, off_summary_rates, "s-", color="orange") +axs[0, 1].set_xlabel("Epoch") +axs[0, 1].set_ylabel("Off Rate") +axs[0, 1].set_title("Off Rate vs Epoch") +axs[0, 1].tick_params(axis="x", rotation=45) + +# Plot 3: Violin plot of Elevations per Epoch +axs[1, 0].violinplot(all_elevations, positions=range(len(epochs)), widths=0.8, showmeans=True) +axs[1, 0].set_xticks(range(len(epochs))) +axs[1, 0].set_xticklabels(epochs, rotation=45, ha="right") +axs[1, 0].set_xlabel("Epoch") +axs[1, 0].set_ylabel("Elevation [deg]") +axs[1, 0].set_title("Elevation Distribution per Epoch") + +# Plot 4: Violin plot of On Rates per Epoch +axs[1, 1].violinplot(all_on_rates, positions=range(len(epochs)), widths=0.8, showmeans=True) +axs[1, 1].set_xticks(range(len(epochs))) +axs[1, 1].set_xticklabels(epochs, rotation=45, ha="right") +axs[1, 1].set_xlabel("Epoch") +axs[1, 1].set_ylabel("On Rate") +axs[1, 1].set_title("On Rate Distribution per Epoch") + +# Plot 5: Violin plot of Off Rates per Epoch +axs[2, 0].violinplot(all_off_rates, positions=range(len(epochs)), widths=0.8, showmeans=True) +axs[2, 0].set_xticks(range(len(epochs))) +axs[2, 0].set_xticklabels(epochs, rotation=45, ha="right") +axs[2, 0].set_xlabel("Epoch") +axs[2, 0].set_ylabel("Off Rate") +axs[2, 0].set_title("Off Rate Distribution per Epoch") + +# Plot 6: 0.01 Crab Sensitivity Time vs Epoch +axs[2, 1].plot(epochs, crab_001_times, "s-", color="purple") +axs[2, 1].set_xlabel("Epoch") +axs[2, 1].set_ylabel("0.01 Crab Time [h]") +axs[2, 1].set_title("0.01 Crab Sensitivity Time vs Epoch") +axs[2, 1].tick_params(axis="x", rotation=45) + +# Plot 7: Sensitivity vs Average Elevation +# Color points red if epoch year >= 2020 +colors = [ + ( + "red" + if "2020" in epoch + or "2021" in epoch + or "2022" in epoch + or "2023" in epoch + or "2024" in epoch + or "2025" in epoch + or "2026" in epoch + else "blue" + ) + for epoch in epochs +] +axs[3, 0].scatter(avg_elevations, crab_001_times, c=colors, alpha=0.7) +axs[3, 0].set_xlabel("Average Elevation [deg]") +axs[3, 0].set_ylabel("0.01 Crab Time [h]") +axs[3, 0].set_title("Sensitivity vs Elevation") + +# Hide the empty subplot +axs[3, 1].axis("off") + +plt.tight_layout() +plt.savefig(args.output_png, dpi=300, bbox_inches="tight") +print(f"Processed {len(epochs)} files. Plots saved as {args.output_png}") From fa8b930d8c2b215d5f190e966cadc8dcc77cd8fc Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Thu, 4 Jun 2026 20:36:32 +0200 Subject: [PATCH 08/23] skip 3-tel runs --- environment.yml | 4 ++++ release_tests/sources/Crab/plot_all.sh | 2 -- .../sources/Crab/runlist_generator_from_anasum_log.sh | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 161c0e2..8cf2fae 100644 --- a/environment.yml +++ b/environment.yml @@ -2,6 +2,9 @@ name: eventdisplay-release-tests channels: - conda-forge dependencies: + - python>=3.8 + - numpy + - matplotlib - pandoc - pre-commit - towncrier @@ -11,3 +14,4 @@ dependencies: # activate: conda activate eventdisplay-release-tests # update (conda/mamba): conda env update -f environment.yml --prune # update (micromamba): micromamba update -f environment.yml +# update (micromamba): micromamba update -n eventdisplay-release-tests -f environment.yml diff --git a/release_tests/sources/Crab/plot_all.sh b/release_tests/sources/Crab/plot_all.sh index 5486d36..8564882 100755 --- a/release_tests/sources/Crab/plot_all.sh +++ b/release_tests/sources/Crab/plot_all.sh @@ -19,8 +19,6 @@ ODIR="${2}/$CUT" echo "Output directory: $ODIR" mkdir -p "$ODIR" -PDIR=$(pwd) - # copy anasum log files to release test directory for F in $LFIL; do TF=$(basename $F .combined.root) diff --git a/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh b/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh index 913b3b1..033392d 100755 --- a/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh +++ b/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh @@ -99,6 +99,11 @@ do echo "Run $R - log file not found: ${ANASUMLOG}" exit fi + # Skip runs without 4-telescope cuts + if ! grep -q "VGammaHadronCuts::printCutSummary() (ntel=4" "${ANASUMLOG}"; then + echo "RUN $R not a 4-telescope run..skipping" + continue + fi echo "DATADIR ${ANASUMLOG}" # read and extract run info from files INSTRUMENT_EPOCH=$(grep "Instrument epoch selected" "${ANASUMLOG}" | head -n 1 | awk '{print $NF}') From 24b09ae1282608da7c8b06fc7b2c9b4f97b6d3a9 Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Thu, 4 Jun 2026 19:24:14 +0200 Subject: [PATCH 09/23] kaputt runs --- release_tests/sources/Crab/runlist_releaseTestingV6.dat | 2 -- 1 file changed, 2 deletions(-) diff --git a/release_tests/sources/Crab/runlist_releaseTestingV6.dat b/release_tests/sources/Crab/runlist_releaseTestingV6.dat index da6d0e3..e5d6a73 100644 --- a/release_tests/sources/Crab/runlist_releaseTestingV6.dat +++ b/release_tests/sources/Crab/runlist_releaseTestingV6.dat @@ -814,7 +814,6 @@ 104174 104199 104201 -104202 104251 104252 104253 @@ -992,7 +991,6 @@ 113299 113303 113352 -113375 113515 113637 113689 From da66aebfe8bc0a4df8c2db63ccfc2bb722e22205 Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Fri, 5 Jun 2026 13:43:20 +0200 Subject: [PATCH 10/23] new elevation steps --- release_tests/sources/Crab/runlist_generator_from_anasum_log.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh b/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh index 033392d..7783734 100755 --- a/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh +++ b/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh @@ -122,7 +122,7 @@ do OBSL="stdHV" fi ELEV=$(grep "mean elevation" "${ANASUMLOG}" | head -n 1 | awk '{print $3}') - EL=$(echo $ELEV | awk -v e=$ELEV '{if (e > 50 ) {print "SZE"} else if (e > 40 ) {print "MZE"} else if (e > 30 ) {print "LZE"} else {print "BZE"}}') + EL=$(echo $ELEV | awk -v e=$ELEV '{if (e > 60 ) {print "SZE"} else if (e > 45 ) {print "MZE"} else if (e > 35 ) {print "LZE"} else {print "BZE"}}') WOBBLESTRING=$(grep "Wobble offsets (currE)" "${ANASUMLOG}") n_offset=$(echo "$WOBBLESTRING" | head -n 1 | awk '{print $5}') w_offset=$(echo "$WOBBLESTRING" | head -n 1 | awk '{print $7}') From 193f267e40220b3ee53c0d3550059a4e2e22d25a Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sat, 6 Jun 2026 09:35:20 +0200 Subject: [PATCH 11/23] clarify usage --- .gitignore | 1 + release_tests/montecarlo/mc_data_comparison/.gitignore | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 release_tests/montecarlo/mc_data_comparison/.gitignore diff --git a/.gitignore b/.gitignore index e43b0f9..74d54ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +tmpdir diff --git a/release_tests/montecarlo/mc_data_comparison/.gitignore b/release_tests/montecarlo/mc_data_comparison/.gitignore deleted file mode 100644 index 15c6bf7..0000000 --- a/release_tests/montecarlo/mc_data_comparison/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tmpdir From eefe21af841d1b3e05b03b08da1901ad96d21404 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sat, 6 Jun 2026 09:38:33 +0200 Subject: [PATCH 12/23] script consistency --- .../montecarlo/mc_data_comparison/README.md | 97 ++++++++++++++++--- .../mc_data_comparison/compareDatawithMC.sh | 19 ++-- .../Crab/plot_sensitivity_from_anasum_log.py | 5 +- 3 files changed, 97 insertions(+), 24 deletions(-) diff --git a/release_tests/montecarlo/mc_data_comparison/README.md b/release_tests/montecarlo/mc_data_comparison/README.md index a89720b..d971b5e 100644 --- a/release_tests/montecarlo/mc_data_comparison/README.md +++ b/release_tests/montecarlo/mc_data_comparison/README.md @@ -1,20 +1,95 @@ -# MC / data comparison +# MC / Data Comparison -Scripts and tools to compare MC distributions with results from the Crab Nebula. +Scripts and tools to compare Monte Carlo (MC) distributions with observational results from the Crab Nebula. -Fill and plot distributions with +## Quick Start ```console -./compareDatawithMC.sh +./compareDatawithMC.sh ``` -Requires as input: +Where `` specifies the observation conditions: -- MC files for each minor epoch -- Crab mscw results for each minor epoch +- `SZE`: Small zenith angles (0-25°, 0.5° wobble) +- `MZE`: Medium zenith angles (40-50°, 0.5° wobble) +- `LZE`: Large zenith angles (50-70°, 0.5° wobble) +- `WOBBLE`: Large wobble offsets (MC at 1° wobble, summer atmosphere only) -**important:** -first run linking of epochs from `../../sources/Crab/`: `./runlist_generator.sh V6` -(or for any other epoch) +NOTE! The zenith angle bins are different compared to those used in the Crab Nebula analysis. -Output and plots are written as PDFs into the `../../../../EventDisplay_Release_/mc_data_comparison/` directories +## Prerequisites + +### Input Data Requirements + +- MC simulation files for each minor epoch (organized by atmosphere type) +- Crab Nebula mscw results for each minor epoch +- Run lists for Crab observations (generated separately) + +## Preparation Steps + +Before running the comparison, you must generate the Crab run lists: + +```console +# From release_tests/sources/Crab/ +./runlist_generator_from_anasum_log.sh +``` + +This generates run lists for minor epochs, zenith angle ranges, and atmosphere types. +The run lists are saved in `EventDisplay_Release_/Crab/runlists/`. + +## Running the Comparison + +### Step 1: Prepare Run Parameter File + +The `` must contain the following fields (one per line): + +```text +* VERSION # e.g., V6 +* SIMTYPE # e.g., CARE, CARE_RedHV +* ATMOSPHERE # e.g., 61*, 62* +* EPOCH # e.g., V4*, V5*, V6* +* CRAB_NSB # e.g., 0, 1, or NOTSET +``` + +Fields marked with `*` support wildcards for multiple values. + +### Step 2: Execute Comparison + +```console +cd release_tests/montecarlo/mc_data_comparison/ +./compareDatawithMC.sh SZE +``` + +This will: + +1. Parse the run parameter file +2. Locate MC simulation files based on epoch and atmosphere +3. Find corresponding Crab observational data +4. Submit Condor jobs for each combination +5. Generate comparison plots as PDF files + +### Step 3: Monitor Progress + +- Condor jobs are submitted with resource requests: 4000MB RAM, 10GB disk +- Temporary symbolic links are created in: `{output_dir}/tmp/{uuid}/` +- **Note**: Temporary directories must be cleaned up manually after completion + +## Output Structure + +Results are written to: + +```text +EventDisplay_Release_/mc_data_comparison/// +├── _ATM___/ +│ ├── mcdatacomparison.runparameter +│ ├── mcdatacomparison.root +│ ├── mcdatacomparison.log +│ └── *.pdf # Comparison plots +└── tmp/ # Temporary symlinks (manual cleanup required) +``` + +## Special Cases + +- **CARE_RedHV simulations**: Handled with modified BDT cut (BDT=0 instead of 1) +- **Summer vs Winter Atmosphere**: Automatically selected based on epoch suffix ('s' or 'w') +- **Wobble Mode**: Forces atmosphere 61 (summer) and 1.0° wobble offset diff --git a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh index 440978b..0a58bca 100755 --- a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh +++ b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh @@ -4,13 +4,13 @@ # # requires: # - MC files for each minor epoch -# - Crab results for each minor epoch (read from Crab runlists; used pre-processed data) +# - Crab results for each minor epoch (read from Crab run lists; used pre-processed data) set -e if [[ $# < 2 ]]; then echo " - ./compareDatawithMC.sh + ./compareDatawithMC.sh --> choose zenith angle / wobble range SZE: small zenith angles (0.5 deg wobble) MZE: medium large zenith angles (0.5 deg wobble) @@ -23,9 +23,9 @@ exit fi ########################### -# read runparameter file +# read run parameter file if [[ ! -e ${1} ]]; then - echo "Error, runparameter file not found: ${1}" + echo "Error, run parameter file not found: ${1}" exit fi # Eventdisplay version @@ -58,10 +58,8 @@ fi # Directory for simulations SIMDIR=${VERITAS_IRFPRODUCTION_DIR}/${VERSION}/${ANALYSISTYPE}/$SIMTYPE/ if [[ ! -e ${SIMDIR} ]]; then - if [[ ! -e ${SIMDIR} ]]; then - echo "Error: simulation directory not found: $SIMDIR" - exit - fi + echo "Error: simulation directory not found: $SIMDIR" + exit fi # Directory for mscw data files DDIR="$VERITAS_PREPROCESSED_DATA_DIR/${ANALYSISTYPE}/mscw/" @@ -123,7 +121,7 @@ do ZEMAX="50." elif [[ $ELE = "LZE" ]] then - ZEMIN="50" + ZEMIN="50." ZEMAX="70." simfile="55deg_${MCWOFF}wob_NOISE${NSB}.mscw.root" # wobble set (everything not 0.5 deg) @@ -216,8 +214,5 @@ do $EVNDISPSCRIPTS/helper_scripts/UTILITY.condorSubmission.sh ${FSCRIPT}.sh 4000M 10G condor_submit ${FSCRIPT}.sh.condor - continue - - done done diff --git a/release_tests/sources/Crab/plot_sensitivity_from_anasum_log.py b/release_tests/sources/Crab/plot_sensitivity_from_anasum_log.py index 772eddd..1409d6a 100644 --- a/release_tests/sources/Crab/plot_sensitivity_from_anasum_log.py +++ b/release_tests/sources/Crab/plot_sensitivity_from_anasum_log.py @@ -32,7 +32,9 @@ if not os.path.isdir(args.input_dir): raise SystemExit(f"Input directory does not exist: {args.input_dir}") -log_files = sorted(glob.glob(os.path.join(args.input_dir, "*anasum*.log"))) +log_files = sorted( + glob.glob(os.path.join(args.input_dir, "*anasum*V6_20*ATM*SZE_0.5deg.combined.log")) +) if not log_files: raise SystemExit(f"No anasum log files found in: {args.input_dir}") @@ -46,6 +48,7 @@ all_off_rates = [] for filepath in log_files: + print(f"Processing file: {filepath}") with open(filepath, "r") as f: content = f.read() From 99d2c94d23b66de803fbfc2444f44b01eb4c594f Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Sat, 6 Jun 2026 09:47:39 +0200 Subject: [PATCH 13/23] apptainer note --- release_tests/montecarlo/mc_data_comparison/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release_tests/montecarlo/mc_data_comparison/README.md b/release_tests/montecarlo/mc_data_comparison/README.md index d971b5e..6a61489 100644 --- a/release_tests/montecarlo/mc_data_comparison/README.md +++ b/release_tests/montecarlo/mc_data_comparison/README.md @@ -1,5 +1,7 @@ # MC / Data Comparison +**No apptainer usage!** + Scripts and tools to compare Monte Carlo (MC) distributions with observational results from the Crab Nebula. ## Quick Start From 470c1fc9905cbb475d85b3e242c45bda94e8fa97 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sun, 12 Jul 2026 17:32:52 +0200 Subject: [PATCH 14/23] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- release_tests/utilities/parameters.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_tests/utilities/parameters.C b/release_tests/utilities/parameters.C index cf49eeb..348cae0 100644 --- a/release_tests/utilities/parameters.C +++ b/release_tests/utilities/parameters.C @@ -56,7 +56,7 @@ bool loadVAnaSumLibrary() { // Use gROOT->ProcessLine to properly load the library and its dictionaries string loadCmd = "R__LOAD_LIBRARY(" + iLibPath + ");"; - int result = gROOT->ProcessLine( loadCmd.c_str() ); + Longptr_t result = gROOT->ProcessLine( loadCmd.c_str() ); if( result >= 0 ) { iLibraryLoaded = true; From 4c1e6a8d9f073856b43963ad8c4ba85be83378e9 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sun, 12 Jul 2026 17:33:04 +0200 Subject: [PATCH 15/23] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- release_tests/utilities/parameters.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_tests/utilities/parameters.C b/release_tests/utilities/parameters.C index 348cae0..5b2f35d 100644 --- a/release_tests/utilities/parameters.C +++ b/release_tests/utilities/parameters.C @@ -65,7 +65,7 @@ bool loadVAnaSumLibrary() } // Try with just the library name - int result = gROOT->ProcessLine( "R__LOAD_LIBRARY(libVAnaSum.so);" ); + Longptr_t result = gROOT->ProcessLine( "R__LOAD_LIBRARY(libVAnaSum.so);" ); if( result >= 0 ) { iLibraryLoaded = true; From d7dd1ff784012e03f5a115749e5134409895af18 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Sun, 12 Jul 2026 17:33:20 +0200 Subject: [PATCH 16/23] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- release_tests/sources/Crab/runlist_generator_from_anasum_log.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh b/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh index 7783734..95470a8 100755 --- a/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh +++ b/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh @@ -101,7 +101,7 @@ do fi # Skip runs without 4-telescope cuts if ! grep -q "VGammaHadronCuts::printCutSummary() (ntel=4" "${ANASUMLOG}"; then - echo "RUN $R not a 4-telescope run..skipping" + echo "Run $R is not a 4-telescope run; skipping" continue fi echo "DATADIR ${ANASUMLOG}" From 4bc64c8cc485d3a38d151a21f867bf1815d16cb0 Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Sat, 6 Jun 2026 10:18:30 +0200 Subject: [PATCH 17/23] fix directory setting --- .../montecarlo/mc_data_comparison/compareDatawithMC.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh index 0a58bca..dc06531 100755 --- a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh +++ b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh @@ -76,8 +76,9 @@ if [[ ! -e ${CDIR} ]]; then fi # output directory for MC/Data comparison -BDIR=$(readlink -f "../../../../EventDisplay_Release_${VERSION}/mc_data_comparison/${ANALYSISTYPE}${DIRRECOTYPE}/${SIMTYPE}/") +BDIR="../../../../EventDisplay_Release_${VERSION}/mc_data_comparison/${ANALYSISTYPE}${DIRRECOTYPE}/${SIMTYPE}/" mkdir -p ${BDIR} +BDIR=$(readlink -f "../../../../EventDisplay_Release_${VERSION}/mc_data_comparison/${ANALYSISTYPE}${DIRRECOTYPE}/${SIMTYPE}/") echo "Results will be written to $BDIR" PWDIR=$(pwd) From 36a9f4e793f4c45a68fd8e707ad82612bdc5c155 Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Thu, 16 Jul 2026 10:19:23 +0200 Subject: [PATCH 18/23] script improvements; XGB --- .../montecarlo/mc_data_comparison/README.md | 8 +- .../mc_data_comparison/compareDatawithMC.sh | 80 +++++++++++++------ .../compareDatawithMC_qsub.sh | 3 +- 3 files changed, 62 insertions(+), 29 deletions(-) diff --git a/release_tests/montecarlo/mc_data_comparison/README.md b/release_tests/montecarlo/mc_data_comparison/README.md index 6a61489..5596bb7 100644 --- a/release_tests/montecarlo/mc_data_comparison/README.md +++ b/release_tests/montecarlo/mc_data_comparison/README.md @@ -48,12 +48,12 @@ The `` must contain the following fields (one per line): ```text * VERSION # e.g., V6 * SIMTYPE # e.g., CARE, CARE_RedHV -* ATMOSPHERE # e.g., 61*, 62* -* EPOCH # e.g., V4*, V5*, V6* +* ATMOSPHERE # e.g., 61, 62 (repeat line for multiple values) +* EPOCH [nsb] # e.g., V6_2019_2020s 0 * CRAB_NSB # e.g., 0, 1, or NOTSET ``` -Fields marked with `*` support wildcards for multiple values. +The leading `*` is part of the parameter-file syntax. To provide multiple atmospheres or epochs, repeat the corresponding line. If `CRAB_NSB` is `NOTSET`, the script reads the per-epoch NSB value from the optional 4th field of each `* EPOCH ...` line. ### Step 2: Execute Comparison @@ -94,4 +94,4 @@ EventDisplay_Release_/mc_data_comparison// $ODIR/mcdatacomparison.runparameter + if [[ $SIMTYPE == "CARE_RedHV"* ]]; then + SIMATM="61" + echo "* SIMS $SIMDIR/${I}_ATM${SIMATM}_gamma/${SIMMSCW}/${simfile} 4 ${MCWOFF} 0. 0. 0. ${ZEMIN} ${ZEMAX}" > $ODIR/mcdatacomparison.runparameter else - if [[ $ELE == "WOBBLE" ]] && [[ ${I: -1} == "s" ]]; then - echo "* SIMS $SIMDIR/${I}_ATM62_gamma/${SIMMSCW}/${simfile} 4 ${MCWOFF} 0. 0. 0. ${ZEMIN} ${ZEMAX}" > $ODIR/mcdatacomparison.runparameter - else - echo "* SIMS $SIMDIR/${I}_ATM${atm}_gamma/${SIMMSCW}/${simfile} 4 ${MCWOFF} 0. 0. 0. ${ZEMIN} ${ZEMAX}" > $ODIR/mcdatacomparison.runparameter - fi + echo "* SIMS $SIMDIR/${I}_ATM${SIMATM}_gamma/${SIMMSCW}/${simfile} 4 ${MCWOFF} 0. 0. 0. ${ZEMIN} ${ZEMAX}" > $ODIR/mcdatacomparison.runparameter fi echo "* ON ${DMSCWDIR}/[0-9]*.mscw.root 4 -99. -99. 0. 360. ${ZEMIN} ${ZEMAX}" >> $ODIR/mcdatacomparison.runparameter echo "* OFF ${DMSCWDIR}/[0-9]*.mscw.root 4 -99. -99. 0. 360. ${ZEMIN} ${ZEMAX}" >> $ODIR/mcdatacomparison.runparameter @@ -206,8 +237,9 @@ do FSCRIPT="$DMSCWDIR/compareDatawithMC_qsub_${SIMTYPE}_${I}${A}_${ELE}_${MCWOFF}_${NSB}" rm -f ${FSCRIPT}.sh sed -e "s|OUTDIR|$ODIR|" \ - -e "s|EEPOCHTM|${I}_ATM${atm}|" \ - -e "s|CURRENTDIR|$PWDIR|" compareDatawithMC_qsub.sh > ${FSCRIPT}.sh + -e "s|EEPOCHTM|${I}_ATM${SIMATM}|" \ + -e "s|CURRENTDIR|$PWDIR|" \ + -e "s|METHODRECO|$RECOMETHOD|" compareDatawithMC_qsub.sh > ${FSCRIPT}.sh echo "Run script: $FSCRIPT" chmod u+x $FSCRIPT.sh diff --git a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh index 080398f..59455dc 100755 --- a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh +++ b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh @@ -7,6 +7,7 @@ source $EVNDISPSYS/setObservatory.sh VTS ODIR=OUTDIR CDIR=CURRENTDIR EPOCHATM=EEPOCHTM +RECOMETHOD=METHODRECO BDT="1" if [[ ${ODIR} == *"CARE_RedHV"* ]]; then @@ -20,7 +21,7 @@ $EVNDISPSYS/bin/compareDatawithMC \ $ODIR/mcdatacomparison.runparameter \ -3 \ $ODIR/mcdatacomparison.root \ - ${BDT} $EPOCHATM \ + ${BDT} $EPOCHATM $RECOMETHOD \ > $ODIR/mcdatacomparison.log # prepare all plots From bdcdfb179c3c293cfa4305b4d4390488e30a60e6 Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Thu, 16 Jul 2026 10:32:20 +0200 Subject: [PATCH 19/23] linking --- .../montecarlo/mc_data_comparison/compareDatawithMC.sh | 8 ++++++-- .../mc_data_comparison/compareDatawithMC_qsub.sh | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh index 5d6edb6..ecaee8f 100755 --- a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh +++ b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh @@ -55,6 +55,10 @@ fi # Stereo reconstruction method # (0: dispBDT, 2: XGB) RECOMETHOD=0 +STEREOMETHOD="" +if [[ $RECOMETHOD == 2 ]]; then + STEREOMETHOD="_XGB" +fi ########################### # elevation range @@ -88,9 +92,9 @@ if [[ ! -e ${CDIR} ]]; then fi # output directory for MC/Data comparison -BDIR="../../../../EventDisplay_Release_${VERSION}/mc_data_comparison/${ANALYSISTYPE}${DIRRECOTYPE}/${SIMTYPE}/" +BDIR="../../../../EventDisplay_Release_${VERSION}/mc_data_comparison/${ANALYSISTYPE}${DIRRECOTYPE}${STEREOMETHOD}/${SIMTYPE}/" mkdir -p ${BDIR} -BDIR=$(readlink -f "../../../../EventDisplay_Release_${VERSION}/mc_data_comparison/${ANALYSISTYPE}${DIRRECOTYPE}/${SIMTYPE}/") +BDIR=$(readlink -f "../../../../EventDisplay_Release_${VERSION}/mc_data_comparison/${ANALYSISTYPE}${DIRRECOTYPE}${STEREOMETHOD}/${SIMTYPE}/") echo "Results will be written to $BDIR" PWDIR=$(pwd) diff --git a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh index 59455dc..ad1b0f0 100755 --- a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh +++ b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh @@ -9,7 +9,7 @@ CDIR=CURRENTDIR EPOCHATM=EEPOCHTM RECOMETHOD=METHODRECO -BDT="1" +BDT="0" if [[ ${ODIR} == *"CARE_RedHV"* ]]; then BDT="0" fi From 10ebba1dca03f4a2d46e4314f61677999acc464f Mon Sep 17 00:00:00 2001 From: Gernot Maier Date: Thu, 16 Jul 2026 10:34:00 +0200 Subject: [PATCH 20/23] xgb linking --- .../montecarlo/mc_data_comparison/compareDatawithMC.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh index ecaee8f..7335918 100755 --- a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh +++ b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh @@ -216,6 +216,14 @@ do exit 1 fi ln -s -f "${MSCWFILE}" "$DMSCWDIR"/"$D".mscw.root + if [[ ${RECOMETHOD} -eq 2 ]]; then + XGBFILE="${MSCWFILE%.mscw.root}.mscw.xgb_stereo.root" + if [[ ! -e "${XGBFILE}" ]]; then + echo "Error: XGB stereo file not found for run ${D}: ${XGBFILE}" + exit 1 + fi + ln -s -f "${XGBFILE}" "$DMSCWDIR"/"$D".mscw.xgb_stereo.root + fi done echo "TEMP DIRECTORY (to be deleted by hand): $DMSCWDIR" From 987b9cc13de693d879e39b61b307dd50f84327ed Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Fri, 24 Jul 2026 16:44:59 +0200 Subject: [PATCH 21/23] all run lists --- .../mc_data_comparison/compareDatawithMC.sh | 90 +++++++++++++------ 1 file changed, 65 insertions(+), 25 deletions(-) diff --git a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh index 7335918..ef1f845 100755 --- a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh +++ b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh @@ -39,6 +39,10 @@ ATMOS=($(awk '$1 == "*" && $2 == "ATMOSPHERE" {print $3}' "${RUNPAR}")) EPOCH=($(awk '$1 == "*" && $2 == "EPOCH" {print $3}' "${RUNPAR}")) # Wobble (default observing; WOBBLE mode fixed to 1 deg) MCWOFF="0.5" +# Hardwired MC epoch for major-epoch (non-minor-epoch) run lists. +# The data run-list epoch and output names remain V6, but the MC files come +# from this minor epoch. +NON_EPOCH_MC_EPOCH="V6_2012_2013a" # Crab NSB level CRABNSB=$(awk '$1 == "*" && $2 == "CRAB_NSB" {print $3; exit}' "${RUNPAR}") # Analysis type @@ -54,7 +58,7 @@ if [[ ! -z $VERITAS_ANALYSIS_TYPE ]]; then fi # Stereo reconstruction method # (0: dispBDT, 2: XGB) -RECOMETHOD=0 +RECOMETHOD=2 STEREOMETHOD="" if [[ $RECOMETHOD == 2 ]]; then STEREOMETHOD="_XGB" @@ -72,7 +76,7 @@ case "$ELE" in ;; esac # Directory for simulations -SIMDIR=${VERITAS_IRFPRODUCTION_DIR}/${VERSION}/${ANALYSISTYPE}/$SIMTYPE/ +SIMDIR=${VERITAS_IRFPRODUCTION_DIR}/${VERSION}_fs25/${ANALYSISTYPE}/$SIMTYPE/ if [[ ! -e ${SIMDIR} ]]; then echo "Error: simulation directory not found: $SIMDIR" exit @@ -128,12 +132,14 @@ get_mscw_file() for I in "${EPOCH[@]}" do - # ignore major epoch - if [[ $I == "V6" ]]; then - continue + MC_EPOCH="${I}" + if [[ "${I}" == "V6" ]]; then + MC_EPOCH="${NON_EPOCH_MC_EPOCH}" fi # Crab NSB level (depends on epoch) - if [[ $CRABNSB == "NOTSET" ]]; then + # If CRAB_NSB is omitted, use the per-epoch value as well. This supports + # parameter files whose EPOCH lines already contain the NSB value. + if [[ -z "${CRABNSB}" || $CRABNSB == "NOTSET" ]]; then NSB=$(awk -v epoch="${I}" '$1 == "*" && $2 == "EPOCH" && $3 == epoch {print $4; exit}' "${RUNPAR}") else NSB=${CRABNSB} @@ -184,26 +190,59 @@ do REDHV="_redHV" fi SIMATM="${atm}" - echo "Processing $I $A ${atm} $REDHV" + echo "Processing $I $A ${atm} $REDHV (MC epoch ${MC_EPOCH})" - # Crab run list - RUNLIST="$CDIR/runlist_releaseTesting${I}${REDHV}_${ELE}_0.5deg.dat" + # Crab run lists. If both atmosphere-specific and generic lists exist, + # analyse both. Generic-list output gets a distinct suffix below. + RUNLISTS=() + RUNLISTTAGS=() if [[ $ELE = "WOBBLE" ]]; then - RUNLIST="$CDIR/runlist_releaseTesting${I}${REDHV}_${ELE}.dat" - fi - echo "RUNLIST $RUNLIST" - if [[ ! -f "$RUNLIST" ]]; then - echo "..not found, skipping" - continue + RUNLISTS+=("$CDIR/runlist_releaseTesting${I}${REDHV}_${ELE}.dat") + RUNLISTTAGS+=("") + else + ATM_RUNLIST="$CDIR/runlist_releaseTesting${I}${REDHV}_ATM${atm}_${ELE}_0.5deg.dat" + if [[ ! -f "$ATM_RUNLIST" ]]; then + ATM_RUNLIST="$CDIR/runlist_releaseTesting${I}${REDHV}_ATM${atm}_${ELE}.dat" + fi + if [[ -f "$ATM_RUNLIST" ]]; then + RUNLISTS+=("$ATM_RUNLIST") + RUNLISTTAGS+=("") + fi + + GENERIC_RUNLIST="$CDIR/runlist_releaseTesting${I}${REDHV}_${ELE}_0.5deg.dat" + if [[ ! -f "$GENERIC_RUNLIST" ]]; then + # Major-epoch or combined lists may not carry the 0.5deg suffix, + # e.g. runlist_releaseTestingV6_SZE.dat. + GENERIC_RUNLIST="$CDIR/runlist_releaseTesting${I}${REDHV}_${ELE}.dat" + fi + if [[ -f "$GENERIC_RUNLIST" ]]; then + RUNLISTS+=("$GENERIC_RUNLIST") + RUNLISTTAGS+=("_ALL") + fi fi - NFIL=$(wc -l < "$RUNLIST") - if [ "$NFIL" -lt 3 ]; then - echo "..not enough runs ($NFIL), skipping" - continue + + if [[ ${#RUNLISTS[@]} -eq 0 ]]; then + RUNLISTS+=("$CDIR/runlist_releaseTesting${I}${REDHV}_${ELE}_0.5deg.dat") + RUNLISTTAGS+=("") fi - # output directory - ODIR=${BDIR}/${I}${A}_${ELE}_${MCWOFF}_${NSB} + for RUNLIST_INDEX in "${!RUNLISTS[@]}" + do + RUNLIST="${RUNLISTS[RUNLIST_INDEX]}" + RUNLISTTAG="${RUNLISTTAGS[RUNLIST_INDEX]}" + echo "RUNLIST $RUNLIST" + if [[ ! -f "$RUNLIST" ]]; then + echo "..not found, skipping" + continue + fi + NFIL=$(wc -l < "$RUNLIST") + if [ "$NFIL" -lt 3 ]; then + echo "..not enough runs ($NFIL), skipping" + continue + fi + + # output directory + ODIR=${BDIR}/${I}${A}${RUNLISTTAG}_${ELE}_${MCWOFF}_${NSB} mkdir -p ${ODIR} # tmp mscw file in output directory @@ -238,18 +277,18 @@ do # write run parameter file if [[ $SIMTYPE == "CARE_RedHV"* ]]; then SIMATM="61" - echo "* SIMS $SIMDIR/${I}_ATM${SIMATM}_gamma/${SIMMSCW}/${simfile} 4 ${MCWOFF} 0. 0. 0. ${ZEMIN} ${ZEMAX}" > $ODIR/mcdatacomparison.runparameter + echo "* SIMS $SIMDIR/${MC_EPOCH}_ATM${SIMATM}_gamma/${SIMMSCW}/${simfile} 4 ${MCWOFF} 0. 0. 0. ${ZEMIN} ${ZEMAX}" > $ODIR/mcdatacomparison.runparameter else - echo "* SIMS $SIMDIR/${I}_ATM${SIMATM}_gamma/${SIMMSCW}/${simfile} 4 ${MCWOFF} 0. 0. 0. ${ZEMIN} ${ZEMAX}" > $ODIR/mcdatacomparison.runparameter + echo "* SIMS $SIMDIR/${MC_EPOCH}_ATM${SIMATM}_gamma/${SIMMSCW}/${simfile} 4 ${MCWOFF} 0. 0. 0. ${ZEMIN} ${ZEMAX}" > $ODIR/mcdatacomparison.runparameter fi echo "* ON ${DMSCWDIR}/[0-9]*.mscw.root 4 -99. -99. 0. 360. ${ZEMIN} ${ZEMAX}" >> $ODIR/mcdatacomparison.runparameter echo "* OFF ${DMSCWDIR}/[0-9]*.mscw.root 4 -99. -99. 0. 360. ${ZEMIN} ${ZEMAX}" >> $ODIR/mcdatacomparison.runparameter echo " run parameter file: $ODIR/mcdatacomparison.runparameter" - FSCRIPT="$DMSCWDIR/compareDatawithMC_qsub_${SIMTYPE}_${I}${A}_${ELE}_${MCWOFF}_${NSB}" + FSCRIPT="$DMSCWDIR/compareDatawithMC_qsub_${SIMTYPE}_${I}${A}${RUNLISTTAG}_${ELE}_${MCWOFF}_${NSB}" rm -f ${FSCRIPT}.sh sed -e "s|OUTDIR|$ODIR|" \ - -e "s|EEPOCHTM|${I}_ATM${SIMATM}|" \ + -e "s|EEPOCHTM|${MC_EPOCH}_ATM${SIMATM}|" \ -e "s|CURRENTDIR|$PWDIR|" \ -e "s|METHODRECO|$RECOMETHOD|" compareDatawithMC_qsub.sh > ${FSCRIPT}.sh @@ -259,5 +298,6 @@ do $EVNDISPSCRIPTS/helper_scripts/UTILITY.condorSubmission.sh ${FSCRIPT}.sh 4000M 10G condor_submit ${FSCRIPT}.sh.condor + done done done From 86c85d27c7e3414a6e504427e45b6674597906ec Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Sun, 2 Aug 2026 16:18:21 +0200 Subject: [PATCH 22/23] add method --- .../mc_data_comparison/compareDatawithMC_qsub.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh index ad1b0f0..e2d9601 100755 --- a/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh +++ b/release_tests/montecarlo/mc_data_comparison/compareDatawithMC_qsub.sh @@ -14,14 +14,21 @@ if [[ ${ODIR} == *"CARE_RedHV"* ]]; then BDT="0" fi +CUT="-3" +T2="0.035" +XGBSUFFIX="xgb_stereo" +MAXZE="20." +ERECOMETHOD="0" + PP=$(pwd) cd ${CDIR} $EVNDISPSYS/bin/compareDatawithMC \ $ODIR/mcdatacomparison.runparameter \ - -3 \ + $CUT \ $ODIR/mcdatacomparison.root \ - ${BDT} $EPOCHATM $RECOMETHOD \ + ${BDT} $EPOCHATM $ERECOMETHOD \ + ${XGBSUFFIX} ${MAXZE} ${T2} $RECOMETHOD \ > $ODIR/mcdatacomparison.log # prepare all plots From aeb4dc0ed5336671b1b45ace03cd9c8cd01082be Mon Sep 17 00:00:00 2001 From: GernotMaier Date: Wed, 5 Aug 2026 09:51:18 +0200 Subject: [PATCH 23/23] add flexibility in anasum directory --- .../Crab/runlist_generator_from_anasum_log.sh | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh b/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh index 95470a8..5e881d4 100755 --- a/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh +++ b/release_tests/sources/Crab/runlist_generator_from_anasum_log.sh @@ -78,16 +78,19 @@ fill_run() get_anasum_log_file() { - data_dir="${1}" - runn="${2}" - if [ ! -e ${data_dir}/$runn.anasum.log ]; then - if [[ ${runn} -lt 100000 ]]; then - EDIR="${data_dir}/${runn:0:1}/" - else - EDIR="${data_dir}/${runn:0:2}/" - fi + local data_dir="${1}" + local runn="${2}" + local direct_log="${data_dir}/${runn}.anasum.log" + + # Anasum logs may either be stored directly in data_dir or in a + # subdirectory selected from the first one/two run-number digits. + if [[ -e "${direct_log}" ]]; then + echo "${direct_log}" + elif [[ ${runn} -lt 100000 ]]; then + echo "${data_dir}/${runn:0:1}/${runn}.anasum.log" + else + echo "${data_dir}/${runn:0:2}/${runn}.anasum.log" fi - echo "$EDIR/$runn.anasum.log" } echo "READING anasum files from ${DATADIR}"