Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
tmpdir
4 changes: 4 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: eventdisplay-release-tests
channels:
- conda-forge
dependencies:
- python>=3.8
- numpy
- matplotlib
- pandoc
- pre-commit
- towncrier
Expand All @@ -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
1 change: 1 addition & 0 deletions release_tests/montecarlo/irf_plotting/irf_plotting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion release_tests/montecarlo/mc_data_comparison/.gitignore

This file was deleted.

99 changes: 88 additions & 11 deletions release_tests/montecarlo/mc_data_comparison/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,97 @@
# MC / data comparison
# MC / Data Comparison

Scripts and tools to compare MC distributions with results from the Crab Nebula.
**No apptainer usage!**

Fill and plot distributions with
Scripts and tools to compare Monte Carlo (MC) distributions with observational results from the Crab Nebula.

## Quick Start

```console
./compareDatawithMC.sh <runparameter file> <SZE/MZE/LZE/WOBBLE>
./compareDatawithMC.sh <runparameter file> <SZE|MZE|LZE|WOBBLE>
```

Requires as input:
Where `<SZE|MZE|LZE|WOBBLE>` specifies the observation conditions:

- `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)

NOTE! The zenith angle bins are different compared to those used in the Crab Nebula analysis.

## 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 <run parameter file> <anasum-results-directory>
```

This generates run lists for minor epochs, zenith angle ranges, and atmosphere types.
The run lists are saved in `EventDisplay_Release_<version>/Crab/runlists/`.

## Running the Comparison

### Step 1: Prepare Run Parameter File

The `<run parameter file>` must contain the following fields (one per line):

- MC files for each minor epoch
- Crab mscw results for each minor epoch
```text
* VERSION <eventdisplay_version> # e.g., V6
* SIMTYPE <simulation_type> # e.g., CARE, CARE_RedHV
* ATMOSPHERE <atmosphere_id> # e.g., 61*, 62*
* EPOCH <epoch_id> # e.g., V4*, V5*, V6*
* CRAB_NSB <nsb_level> # 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 <path/to/run\ parameter\ file> 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_<version>/mc_data_comparison/<analysis_type><disp>/<simulation_type>/
├── <epoch>_ATM<atm>_<ELE>_<wobble>_<nsb>/
│ ├── mcdatacomparison.runparameter
│ ├── mcdatacomparison.root
│ ├── mcdatacomparison.log
│ └── *.pdf # Comparison plots
└── tmp/ # Temporary symlinks (manual cleanup required)
```

**important:**
first run linking of epochs from `../../sources/Crab/`: `./runlist_generator.sh V6`
(or for any other epoch)
## Special Cases

Output and plots are written as PDFs into the `../../../../EventDisplay_Release_<version>/mc_data_comparison/` directories
- **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
19 changes: 7 additions & 12 deletions release_tests/montecarlo/mc_data_comparison/compareDatawithMC.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <runparameter file> <SZE/MZE/LZE/WOBBLE>
./compareDatawithMC.sh <run parameter file> <SZE/MZE/LZE/WOBBLE>
--> choose zenith angle / wobble range
SZE: small zenith angles (0.5 deg wobble)
MZE: medium large zenith angles (0.5 deg wobble)
Expand All @@ -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
Expand Down Expand Up @@ -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/"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -216,8 +214,5 @@ do
$EVNDISPSCRIPTS/helper_scripts/UTILITY.condorSubmission.sh ${FSCRIPT}.sh 4000M 10G
condor_submit ${FSCRIPT}.sh.condor

continue


done
done
2 changes: 1 addition & 1 deletion release_tests/sources/Crab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ for
Combine files using pre-processed anasum files and run list generated in step before:

```bash
./anasum_yearly.sh <runparameter file> <anasum-run-wise directory>
./anasum_from_runlists.sh <run-parameter file> <anasum-run-wise directory>
```

## Plotting
Expand Down
2 changes: 0 additions & 2 deletions release_tests/sources/Crab/plot_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions release_tests/sources/Crab/plot_energy_spectra.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "TF1.h"

R__LOAD_LIBRARY($EVNDISPSYS/lib/libVAnaSum.so)

#include "../../utilities/parameters.C"
#include "../../utilities/printutilities.C"

Expand Down
2 changes: 2 additions & 0 deletions release_tests/sources/Crab/plot_lightcurves.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <string>
#include <vector>

R__LOAD_LIBRARY($EVNDISPSYS/lib/libVAnaSum.so)

#include "../../utilities/parameters.C"
#include "../../utilities/printutilities.C"

Expand Down
1 change: 1 addition & 0 deletions release_tests/sources/Crab/plot_sensitivity.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include <string>
R__LOAD_LIBRARY($EVNDISPSYS/lib/libVAnaSum.so)

#include "../../utilities/parameters.C"
#include "../../utilities/printutilities.C"
Expand Down
Loading
Loading