-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtufts_run_ntuple_maker.sh
More file actions
91 lines (67 loc) · 2.51 KB
/
tufts_run_ntuple_maker.sh
File metadata and controls
91 lines (67 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
JOBSTARTDATE=$(date)
scriptDir="/path/to/repo"
pythonScript="${scriptDir}/$1"
kpsRecoFiles=$2
mdlRecoFiles=$3
weightFile="${scriptDir}/event_weighting/$4"
checkpointDir="/cluster/tufts/wongjiradlabnu/mrosen25/prongCNN/models/checkpoints"
modelPath="${checkpointDir}/$5"
outTag=$6
nfiles=$7
echo "running array ID $SLURM_ARRAY_TASK_ID (sample output tag: $outTag) on node $SLURMD_NODENAME"
ubdlDir="/path/to/ubdl"
source ${ubdlDir}/setenv_py3.sh
source ${ubdlDir}/configure.sh
export PYTHONPATH=${PYTHONPATH}:${scriptDir}
maxFileCount=`wc -l < $kpsRecoFiles`
let firstfile="${SLURM_ARRAY_TASK_ID}*${nfiles}+1"
let lastfile="$firstfile+$nfiles-1"
files=""
for n in $(seq $firstfile $lastfile); do
if (($n > $maxFileCount)); then
break
fi
newfile=`sed -n ${n}p ${kpsRecoFiles}`
files="$files $newfile"
done
scriptName=`echo $1 | sed s/.py//g`
outDir="/path/to/output/directory"
logDir="/path/to/logfile/directory"
logFile="${logDir}/${scriptName}_${outTag}_${SLURM_ARRAY_TASK_ID}.log"
local_jobdir=`printf /tmp/run_selection_jobid%d_%04d ${SLURM_JOB_ID} ${SLURM_ARRAY_TASK_ID}`
rm -rf $local_jobdir
mkdir -p $local_jobdir
cd $local_jobdir
((iF = 0))
outputs=""
for file in $files; do
outFile="${scriptName}_${outTag}_output_${SLURM_ARRAY_TASK_ID}_${iF}.root"
echo "inputfile path: $file" >> ${logFile}
echo "outFile: $outFile" >> ${logFile}
if (($# > 8)); then
echo "python3 $pythonScript -f $file -t $mdlRecoFiles -o $outFile -w $weightFile -m $modelPath $8 $9 >> $logFile"
python3 $pythonScript -f $file -t $mdlRecoFiles -o $outFile -w $weightFile -m $modelPath $8 $9 >> $logFile
elif (($# > 7)); then
echo "python3 $pythonScript -f $file -t $mdlRecoFiles -o $outFile -w $weightFile -m $modelPath $8 >> $logFile"
python3 $pythonScript -f $file -t $mdlRecoFiles -o $outFile -w $weightFile -m $modelPath $8 >> $logFile
else
echo "python3 $pythonScript -f $file -t $mdlRecoFiles -o $outFile -w $weightFile -m $modelPath >> $logFile"
python3 $pythonScript -f $file -t $mdlRecoFiles -o $outFile -w $weightFile -m $modelPath >> $logFile
fi
((iF = iF + 1))
outputs="$outputs $outFile"
done
mergedOutput="${scriptName}_${outTag}_output_${SLURM_ARRAY_TASK_ID}.root"
echo "output files: $outputs" >> ${logFile}
echo "merging into: $mergedOutput" >> ${logFile}
hadd $mergedOutput $outputs
cp $mergedOutput $outDir
# clean-up
rm $outputs
rm $mergedOutput
cd /tmp
rm -r $local_jobdir
JOBENDDATE=$(date)
echo "Job began at $JOBSTARTDATE" >> $logFile
echo "Job ended at $JOBENDDATE" >> $logFile