Skip to content
Merged
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
3 changes: 1 addition & 2 deletions docs/changes/129.maintenance.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
- change of default ROOT version from 6.30 to 6.38.
- modification of script for new Eventdisplay-ML packages.
Modification of script for new Eventdisplay-ML packages.
1 change: 1 addition & 0 deletions docs/changes/131.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update `IRF.selectRunsForGammaHadronSeparationTraining.sh` to new `printRunParameter` option with printout of zenith angle.
17 changes: 10 additions & 7 deletions scripts/IRF.selectRunsForGammaHadronSeparationTraining.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ MINOBSTIME=600
# Sources to avoid
BRIGHTSOURCES=( Crab Mrk421 )

echo "Reference values: ${MEPOCH} ${OBSMODE} ${MULT} ${BRIGHTSOURCES[*]} "
echo "Reference values: ${MEPOCH} ${OBSMODE}"
echo "Multiplicity cut: ${MULT}"
echo "Minimum observing time: ${MINOBSTIME} s"
echo "Avoiding bright sources: ${BRIGHTSOURCES[*]}"

# zenith angle bins
ZEBINS=$( cat "$RUNPAR" | grep "^* ZENBINS " | sed -e 's/* ZENBINS//' | sed -e 's/ /\n/g')
Expand All @@ -57,7 +60,6 @@ linkFile()
fi
}


for F in ${FLIST}
do
echo "LINKING file ${F}.root"
Expand All @@ -66,7 +68,10 @@ do
echo " found..."
continue
fi
RUNZENITH=$($EVNDISPSYS/bin/printRunParameter ${F}.root -zenith | awk '{print $4}')
RUNINFO=$($EVNDISPSYS/bin/printRunParameter ${F}.root -runinfo)
echo " RUNINFO $RUNINFO"

RUNZENITH=$(echo $RUNINFO | awk '{print $8}')
ZEBIN=0
for (( j=0; j < $NZEW; j++ ))
do
Expand All @@ -75,9 +80,7 @@ do
break;
fi
done
echo " Zenith bin: ${ZEBIN}"
RUNINFO=$($EVNDISPSYS/bin/printRunParameter ${F}.root -runinfo)
echo " RUNINFO $RUNINFO"
echo " Zenith bin: ${ZEBIN} for zenith angle ${RUNZENITH}"

TMPMEPOCH=$(echo $RUNINFO | awk '{print $2}')
if [[ ${TMPMEPOCH} != ${MEPOCH} ]]; then
Expand Down Expand Up @@ -115,7 +118,7 @@ do
continue
fi
# ignore runs with zero wobble offsets
RUNWOBBLE=$($EVNDISPSYS/bin/printRunParameter ${F}.root -wobbleInt | awk '{print $3}')
RUNWOBBLE=$(echo "$RUNINFO" | awk '{print $10}')
if [[ $RUNWOBBLE == "0" ]]; then
echo " SKIPPING WOBBLE $RUNWOBBLE"
continue
Expand Down
29 changes: 13 additions & 16 deletions scripts/IRF.trainTMVAforGammaHadronSeparation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@
#

h_cpu=11:59:59; h_vmem=8000M; tmpdir_size=24G
# EventDisplay version
EDVERSION=$(cat $VERITAS_EVNDISP_AUX_DIR/IRFVERSION)

if [ $# -lt 7 ]; then
echo "
TMVA (BDT) training for gamma/hadron separation: submit jobs from a TMVA runparameter file
TMVA (BDT) training for gamma/hadron separation: submit jobs from a TMVA run-parameter file

IRF.trainTMVAforGammaHadronSeparation.sh <background file directory> <TMVA runparameter file> <output directory> <output file name> <sim type> <epoch> <atmosphere>
IRF.trainTMVAforGammaHadronSeparation.sh <background file directory> <TMVA run-parameter file> <output directory> <output file name> <sim type> <epoch> <atmosphere>

required parameters:

<background file directory> directory with background training (mscw) files

<TMVA runparameter file> TMVA runparameter file with basic options (incl. whole range of
<TMVA run-parameter file> TMVA run-parameter file with basic options (incl. whole range of
energy and zenith angle bins) and full path

<output directory> BDT files are written to this directory
Expand Down Expand Up @@ -60,12 +59,12 @@ PARTICLE_TYPE="gamma"
UUID="${12:-$(date +"%y%m%d")-$(uuidgen)}"

echo "Background file directory: $BDIR"
echo "Runparameters: $RUNPAR"
echo "Run parameters: $RUNPAR"
echo "Simulation type: $SIMTYPE"

# Fixed list of NSB levels; redHV needs attention
if [[ ${SIMTYPE} == *"RedHV"* ]]; then
echo "Fixed NSB levels not suitable for RedHV trainging"
echo "Fixed NSB levels not suitable for RedHV training"
exit 1
fi

Expand All @@ -78,7 +77,7 @@ if [[ ! -z $VERITAS_ANALYSIS_TYPE ]]; then
fi
fi

# Check that list of background file directory exists
# Check that background file directory exists
if [[ ! -d "$BDIR" ]]; then
echo "Error, directory with background files $BDIR not found, exiting..."
exit 1
Expand Down Expand Up @@ -110,19 +109,19 @@ RUNPAR_CONTENT=$(cat "$RUNPAR")
# energy bins
if echo "$RUNPAR_CONTENT" | grep -q "^\* ENERGYBINS"; then
ENBINS=$(echo "$RUNPAR_CONTENT" | grep "^\* ENERGYBINS" | sed -e 's/* ENERGYBINS//' | sed -e 's/ /\n/g')
declare -a EBINARRAY=( $ENBINS ) #convert to array
declare -a EBINARRAY=( $ENBINS ) # convert to array
count1=1
NENE=$((${#EBINARRAY[@]}-$count1)) #get number of bins
NENE=$((${#EBINARRAY[@]}-$count1)) # get number of bins
for (( i=0; i < $NENE; i++ ))
do
EBINMIN[$i]=${EBINARRAY[$i]}
EBINMAX[$i]=${EBINARRAY[$i+1]}
done
else
ENBINS=$(echo "$RUNPAR_CONTENT" | grep "^\* ENERGYBINEDGES" | sed -e 's/* ENERGYBINEDGES//' | sed -e 's/ /\n/g')
declare -a EBINARRAY=( $ENBINS ) #convert to array
declare -a EBINARRAY=( $ENBINS ) # convert to array
count1=1
NENE=$((${#EBINARRAY[@]}-$count1)) #get number of bins
NENE=$((${#EBINARRAY[@]}-$count1)) # get number of bins
z="0"
for (( i=0; i < $NENE; i+=2 ))
do
Expand All @@ -141,7 +140,7 @@ NZEW=$((${#ZEBINARRAY[@]}-$count1)) #get number of bins

#####################################
# zenith angle bins of MC simulation files
ZENITH_ANGLES=( 20 30 35 40 45 50 55 60 )
ZENITH_ANGLES=( 20 30 35 40 45 50 55 60 65)


####################################
Expand All @@ -161,14 +160,12 @@ get_run_prefix()
SUBSCRIPT=$(dirname "$0")"/helper_scripts/IRF.trainTMVAforGammaHadronSeparation_sub"

###############################################################
# loop over all energy bins and submit a job for each bin
# loop over all energy/zenith bins and submit a job for each bin
for (( i=0; i < $NENE; i++ ))
do
echo "==========================================================================="
echo " "
echo "Energy Bin: $(($i+$count1)) of $NENE: ${EBINMIN[$i]} to ${EBINMAX[$i]} (in log TeV)"
##############################################
# loop over all zenith angle bins
for (( j=0; j < $NZEW; j++ ))
do
echo "---------------------------------------------------------------------------"
Expand Down Expand Up @@ -217,7 +214,7 @@ do
for (( l=0; l < ${#ZENITH_ANGLES[@]}; l++ ))
do
if (( $(echo "${ZEBINARRAY[$j]} <= ${ZENITH_ANGLES[$l]}" | bc ) && $(echo "${ZEBINARRAY[$j+1]} >= ${ZENITH_ANGLES[$l]}" | bc ) ));then
if (( "${ZENITH_ANGLES[$l]}" != "00" && "${ZENITH_ANGLES[$l]}" != "60" && "${ZENITH_ANGLES[$l]}" != "65" )); then
if (( "${ZENITH_ANGLES[$l]}" != "00" )); then
for arg in "$SDIR"/${ZENITH_ANGLES[$l]}deg_0.5wob_NOISE{100,160,200,250,350,450}.mscw.root; do
echo "* SIGNALFILE SIMDIR/${arg##*/}"
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,11 @@ fi

# effective area - fill path
EFFAREA="$VERITAS_EVNDISP_AUX_DIR/EffectiveAreas/${EFFAREA}"

# epoch / ATM
EPAT="${EPOCH}_ATM${ATM}"

# output directory
WDIR="${PREDIR}/Optimize-${CUT}/"
mkdir -p ${WDIR}

# rates files
RATEFILE="${WDIR}/rates_${EPAT}"

Expand All @@ -67,7 +64,6 @@ then
> ${RATEFILE}.log
fi

# optimize cuts
echo "optimize cuts..."
MVADIR="$VERITAS_EVNDISP_AUX_DIR/GammaHadronBDTs/${VERITAS_ANALYSIS_TYPE:0:2}/${EPAT}/${CUT}/"
cd ${PREDIR}/${CUT}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash
# script to train TMVA (BDTs) for gamma/hadron separation

# parameters replaced by parent script using sed
RXPAR=RUNPARAM
SIMDIR=MCDIRECTORY
DDIR=DATADIRECTORY
Expand Down