Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-05-23 08:12:15

0001 #!/bin/bash
0002 
0003 export USER="$(id -u -n)"
0004 export LOGNAME=${USER}
0005 export HOME=/sphenix/u/${LOGNAME}/macros/detectors/sPHENIX/
0006 export MYINSTALL=/sphenix/user/bkimelman/sPHENIX/install/
0007 
0008 source /opt/sphenix/core/bin/sphenix_setup.sh -n
0009 source /opt/sphenix/core/bin/setup_local.sh $MYINSTALL
0010 
0011 #DIR=/sphenix/tg/tg01/jets/bkimelman/VandyDSTs_wEEC_3D_unfolding_kinematics_Apr30_2026_0p25/
0012 DIR=/sphenix/tg/tg01/jets/bkimelman/VandyDSTs_wEEC_3D_unfolding_kinematics_Apr30_2026_${1}/
0013 run_pipeline() {
0014     local kMode=$1
0015     local pids=()
0016     local failed=0
0017 
0018     echo "Starting pipeline for $kMode"
0019 
0020     # --- step 1: launch jobs in parallel ---
0021     for i in 12 20 30 40 50 60; do
0022         ../run_hadd_unfold.sh $i $DIR response $kMode &
0023         pids+=($!)
0024     done
0025 
0026     # --- wait for step 1 jobs ---
0027     for pid in "${pids[@]}"; do
0028         if ! wait "$pid"; then
0029             echo "ERROR: $kMode job $pid failed" >&2
0030             failed=1
0031         fi
0032     done
0033 
0034     # --- only continue if successful ---
0035     if (( failed )); then
0036         echo "$kMode pipeline failed — skipping final hadd" >&2
0037         return 1
0038     fi
0039 
0040     echo "$kMode step1 complete, starting final hadd"
0041 
0042     # --- step 2: mode-specific hadd ---
0043     if [[ "$kMode" == "kFull" ]]; then
0044         hadd -f "$DIR/response-all-fullClosure.root" "$DIR"/response_Jet*-fullClosure.root
0045         rm "$DIR"/response_Jet*-fullClosure.root
0046     elif [[ "$kMode" == "kHalf" ]]; then
0047         hadd -f "$DIR/response-all-halfClosure.root" "$DIR"/response_Jet*-halfClosure.root
0048         rm "$DIR"/response_Jet*-halfClosure.root
0049     elif [[ "$kMode" == "kData" ]]; then
0050         hadd -f "$DIR/response-all-dataClosure.root" "$DIR"/response_Jet*-dataClosure.root
0051         rm "$DIR"/response_Jet*-dataClosure.root    
0052     elif [[ "$kMode" == "kVtx" ]]; then
0053         hadd -f "$DIR/response-all-vtx.root" "$DIR"/response_Jet*-vtx.root
0054         rm "$DIR"/response_Jet*-vtx.root
0055     fi
0056 
0057     echo "$kMode pipeline complete"
0058 }
0059 
0060 # --- launch both pipelines in parallel ---
0061 run_pipeline kFull &
0062 pid_full=$!
0063 
0064 : '
0065 run_pipeline kHalf &
0066 pid_half=$!
0067 
0068 run_pipeline kData &
0069 pid_data=$!
0070 '
0071 # --- wait for both pipelines and track failures ---
0072 fail_any=0
0073 
0074 if ! wait "$pid_full"; then
0075     echo "kFull pipeline failed" >&2
0076     fail_any=1
0077 fi
0078 
0079 : '
0080 if ! wait "$pid_half"; then
0081     echo "kHalf pipeline failed" >&2
0082     fail_any=1
0083 fi
0084 
0085 if ! wait "$pid_data"; then
0086     echo "kData pipeline failed" >&2
0087     fail_any=1
0088 fi
0089 '
0090 
0091 # --- only run final hadd if both succeeded ---
0092 if (( fail_any )); then
0093     echo "One or more pipelines failed — aborting final hadd" >&2
0094     exit 1
0095 fi
0096 
0097 
0098 echo "Running final data hadd"
0099 
0100 
0101 #hadd -f -j 8 -n 100 "$DIR/data_measured-all.root" "$DIR"/Data/data_measured_*.root
0102 
0103 echo "done with all hadds"