-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunAnalysis.sh
More file actions
executable file
·96 lines (70 loc) · 1.93 KB
/
runAnalysis.sh
File metadata and controls
executable file
·96 lines (70 loc) · 1.93 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
91
92
93
94
95
#!/bin/bash
function readTxtFile() {
counter=0
FILELIST=$1
# TODO: Specify where the PBS script is
PBS_SCRIPT=$HOME/work/BoostedDM/FinalPlot/runAnalysis.pbs
while read CMD; do
echo "Submiting job $counter - Analysis of $CMD ..."
qsub -F "$CMD $2" $PBS_SCRIPT
counter=$((counter + 1))
if (( $counter % 11 == 0)); then
sleep 200
counter=0
fi
done < "$FILELIST"
}
function checkLiveTime(){
# Create script to launch ROOT command
SCRIPT="/tmp/readRunTime.C"
cat > ${SCRIPT}<< EOF
//------------FILE-CONTENT------------//
void readRunTime(const char* filename ){
TFile *_file = new TFile(filename);
auto runtime = (TVectorT<double>*) _file->Get("runtime");
if (runtime->GetNrows() != 1) {
printf("Multiple runtime? Seriously?");
exit(1);
}
std::cout << std::setprecision(20) << runtime->Max() << std::endl;
_file->Close();
}
//------------FILE-CONTENT------------//
EOF
touch $2/runtimeCheck.txt
FILELIST=$1
while read FILE; do
echo "Reading $FILE ..."
CMD="root -l -q '/tmp/readRunTime.C(\"$FILE\")'"
echo $(eval $CMD | tail -1) >> $2/runtimeCheck.txt
done < "$FILELIST"
rm -rf /tmp/readRunTime.C
}
################################
# Main Program #
################################
# Check the right number of args
if [ "$#" -ne 2 ]; then
echo "Usage: ./runAnalysis.sh listOfFilesToAnalyze.txt path/to/output_dir"
exit 1
fi
# Prompt to get user's choice of analysis
CONF_="n"
ANALYSIS_=10
while [ "$CONF_" != "y" ]; do
echo "What kind of analysis would you like to do?"
echo "(1) - Analyzing files"
echo "(2) - Get runtime"
read ANALYSIS_
echo "Confirming ($ANALYSIS_) based analysis ? (y/n)"
read CONF_
done
LISTOFFILES=$1
# Calling function
if [ $ANALYSIS_ -eq 1 ]; then
readTxtFile "${LISTOFFILES}" $2
elif [ $ANALYSIS_ -eq 2 ]; then
# Overwrite outputfile
rm -f $2/runtimeCheck.txt
checkLiveTime "${LISTOFFILES}" $2
fi