ANASEN_analysis/run_17F.sh
Vignesh Sitaraman 8be662d0d1 modified: TrackRecon.C added fine timing correction
modified:   run_17F.sh updating to new format and including some other changes also updated the eloss files for 4%
2026-10-23 10:32:40 -04:00

87 lines
2.8 KiB
Bash

#!/bin/bash
export DATASET="17F"
export PREFIX="Run_"
export OUT_DIR="Output_17F"
export reactiondata=1
export CO2percent=4
export pressure_in_torr=250
export CATHODE_GAIN=1
export source_vertex=-200.0
export DEDX_SCALE=0.962
export CUTLIST=cuts_list.txt
# Spray veto: drop a QQQ/SX3 detector that fires this many hits in one event
# (whole-detector bursts, mostly saturated). SX3 6 is the tighter option.
export QQQ_SPRAY_NCH=7
export SX3_SPRAY_NCH=9
# Cleanups (TrackRecon defaults reproduce the old behaviour when these are unset)
export QQQ_RW_DTMAX=100 # QQQ ring/wedge time coincidence [ns]
export PC_GM_NOWRAP=1 # negative gain-matched PC energies -> 0 instead of ~65000
# To test, one at a time against a reference output:
export SI_ECUT_17F_QQQ=0.45 # was 2.0 MeV
export SI_ECUT_17F_SX3=0.6 # was 1.5 MeV
export QQQ_PC_GATE_17F=0 # drop the QQQ -450..-200 ns pre-gate
export MISC_SWAP_RF_MCP=1 # 405 ch14 = MCP, ch10 = RF; transpose simcprfgate1/2 first
run_once() {
local wrun=$(printf "%03d" "$1")
local prefix="${PREFIX:-Run_}"
local outdir="${OUT_DIR:-Output_default}"
local infile="../ANASEN_analysis/data/${DATASET}_Data/${prefix}${wrun}_mapped.root"
local out="${outdir}/results_run${wrun}.root"
# Skip if the input file doesn't exist (return, not continue — this is a function)
if [ ! -f "$infile" ]; then
echo "SKIP: input $infile not found"
return
fi
# Ensure the directory exists so ROOT doesn't fail silently
mkdir -p "$outdir"
root -q -l -b -x "$infile" \
-e "tree->Process(\"TrackRecon.C+\", \"${out}\")" > /dev/null 2>&1
if [ -f "$out" ]; then
echo "Run $wrun completed successfully in $outdir."
else
echo "ERROR: Run $wrun failed to generate $out"
fi
}
export -f run_once
rm -f ${OUT_DIR}/*.root
echo "Running Eloss.py with a scaling parameter of $DEDX_SCALE"
echo "running with a beam offset of $BEAM_AXIS_X $BEAM_AXIS_Y"
myenv/bin/python eloss_calculations/Eloss.py || { echo "Eloss.py failed"; exit 1; }
# Pre-compile TrackRecon.C ONCE on a single core so parallel jobs don't race on ACLiC
echo "Pre-compiling TrackRecon.C..."
root -q -l -b -e '.L TrackRecon.C++O'
# 3% CO2
# parallel --bar -j 6 run_once ::: {325..400}
parallel --bar -j 11 run_once ::: {351..400}
# parallel --bar -j 7 run_once ::: 351 353 355 358 359 360 362 367
hadd -j 4 -k ${OUT_DIR}/Output_17F.root ${OUT_DIR}/results_run*.root
unset source_vertex
unset DATASET
unset reactiondata
unset CO2percent
unset pressure_in_torr
unset CATHODE_GAIN
unset A1C1_LOWBAND_RFACTOR
unset CUTLIST
unset QQQ_SPRAY_NCH
unset SX3_SPRAY_NCH
unset QQQ_RW_DTMAX
unset PC_GM_NOWRAP
unset SI_ECUT_17F_QQQ
unset SI_ECUT_17F_SX3
unset QQQ_PC_GATE_17F
unset MISC_SWAP_RF_MCP
unset A1C1_Z_SCALE_QQQ
unset A1C1_Z_OFF_QQQ
unset A1C1_Z_OFF_SX3