]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/qa/RunQA.sh
Fixed references from PWG2 -> PWGLF - very efficiently done using ETags.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / qa / RunQA.sh
CommitLineData
2dbde04b 1#!/bin/bash
db2d5aa8 2#
3# This is deprecated. Use RunQAMT.sh instead
4#
2dbde04b 5jobid=0
6top=.
7verb=0
3405bb49 8nodw=0
9notr=0
5e8eab11 10norn=0
bae153e5 11maxf=-1
9a684059 12last="unknown"
13lock=
14
2dbde04b 15
bd6f5206 16export PATH=$PATH:$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa:../scripts
2dbde04b 17
9a684059 18# --- Handle exit ----------------------------------------------------
19handle_exit()
2dbde04b 20{
9a684059 21 echo "Removing $lock"
22 rm -f $lock
23}
24trap handle_exit EXIT
25
26# --- Usage information ----------------------------------------------
27usage()
28{
2dbde04b 29cat <<EOF
30Usage: $0 -j JOBID [OPTIONS]
31
32Options:
33 -h.--help This help
5e8eab11 34 -j,--jobid JOBID Job id from MonALisa [$jobid]
35 -d,--nodownload Do not download [$nodw]
36 -t,--notrend Do not make new trend tree [$notr]
37 -r,--no-run Do not make per-run info [$norn]
38 -o,--output DIRECTORY Where to store the result [$top]
39 -v,--verbose Be verbose [$verb]
bae153e5 40 -m,--max NUMBER Maximum number of runs to get [$maxf]
5e8eab11 41 -s,--skip-lines NUMBER Number of lines to skip in job list [$skip]
2dbde04b 42EOF
9a684059 43}
2dbde04b 44
9a684059 45# --- Messages -------------------------------------------------------
2dbde04b 46mess()
47{
48 if test $verb -lt 1 ; then return ; fi
9a684059 49 last="$@"
2dbde04b 50 echo $@
9a684059 51}
2dbde04b 52
53# --- Get parts of the passed path -----------------------------------
54get_parts()
55{
56 y=$1 ; shift
57 p=$1 ; shift
58 r=$1 ; shift
59 e=$1 ; shift
60 x=$1 ; shift
61 r=$1
62
63 P=`echo $x | sed 's/.*pass\([0-9]*\).*/\1/'`
64 R=`echo $x | sed -n "s/.*pass${P}_//p"`
65 Q=`echo $x | sed -n 's/pass.*//p'`
bae153e5 66 Y=`echo $p | sed 's/LHC\(..\).*/\1/'`
67 L=`echo $p | sed "s/LHC${Y}\(.\).*/\1/"`
68 S=`echo $p | sed "s/LHC${Y}${L}//"`
69
70 dprod=LHC${Y}${L}
71 case x$S in
72 x) ;;
73 x_*) ;;
74 *) dprod=${dprod}${S} ;;
75 esac
2dbde04b 76
77 case x$r in
78 xQA*) q=`echo $r | sed 's/QA//'` ;;
79 x) ;;
80 *) ;;
81 esac
82
83 opts="-p $p -P $P"
84 if test "x$R" != "x" ; then opts="$opts -R $R" ; fi
85 if test "x$q" != "x" ; then opts="$opts -q $q" ; fi
86 if test "x$Q" != "x" ; then opts="$opts -Q $Q" ; fi
87
bae153e5 88 dest="${dprod}/${Q}pass${P}"
2dbde04b 89 if test "x$R" != "x" ; then dest="${dest}_${R}" ; fi
90
91}
92
93# --- Get the options ------------------------------------------------
5e8eab11 94skip=1
9a684059 95jobUrl="http://alimonitor.cern.ch/prod/jobs.jsp?t="
96get_opts() {
97 wget -q ${jobUrl}${jobid} -O job.html
5e8eab11 98 p=`grep "/catalogue/index.jsp?path" job.html | head -n $skip | tail -n 1 | sed -e 's,.*/alice/data/\([^<]*\)<.*,\1,' | tr '/' ' '`
3405bb49 99 rm -f job.html
9a684059 100
2dbde04b 101 get_parts $p
9a684059 102}
103
104# --- Trapping errors ------------------------------------------------
105handle_err()
106{
107 echo "Got an error: $last"
108 exit 1
109}
110enable_trap ()
111{
bae153e5 112 # echo "Enabling trapping errors"
9a684059 113 trap handle_err ERR
bae153e5 114 # trap -p ERR
9a684059 115}
116disable_trap ()
117{
bae153e5 118 # echo "Disabling trapping errors"
9a684059 119 trap - ERR
bae153e5 120 # trap -p ERR
2dbde04b 121}
122
9a684059 123
db2d5aa8 124# --- Deprecated -----------------------------------------------------
125cat <<EOF
126This script is deprecated. You should use the more advanced script RunQAMT.sh
127which process the runs in parallel and in general is more flexible
128EOF
129read -n 1 -i n -p "Do you want to continue [yN]? "
130case $REPLY in
131 y|Y) echo "" ;;
132 *) exit 0 ;;
133esac
134
135
2dbde04b 136# --- comamnd line ---------------------------------------------------
137while test $# -gt 0 ; do
138 case $1 in
3405bb49 139 -h|--help) usage ; exit 0 ;;
140 -j|--jobid) jobid=$2; shift ;;
141 -o|--output) top=$2 ; shift ;;
142 -d|--no-download) nodw=1 ;;
143 -t|--no-trend) notr=1 ;;
5e8eab11 144 -r|--no-run) norn=1 ;;
3405bb49 145 -v|--verbose) verb=1 ;;
5e8eab11 146 -s|--skip-lines) skip=$2 ; shift ;;
bae153e5 147 -m|--max) maxf=$2 ; shift ;;
2dbde04b 148 *) echo "Unknown option $1" > /dev/stderr ; exit 1 ;;
149 esac
150 shift
151done
152
153# --- Sanity ---------------------------------------------------------
154if test $jobid -lt 1 ; then
155 echo "No JOBID specified" > /dev/stderr
156 exit 1
157fi
158
9a684059 159# --- Extract options -----------------------------------------------
2dbde04b 160get_opts $jobid
2dbde04b 161if test "x$opts" = "x" ; then
162 echo "No options found"
9a684059 163 rm -f $lock
2dbde04b 164 exit 1
165fi
166
3405bb49 167# --- Display job setting --------------------------------------------
168cat <<EOF
169----------------------------------------------------------------------
170Job id: $jobid
171Top directory: $top
172Don't download: $nodw
173Don't make tree: $notr
174Download options: $opts
175Destination: $dest
5e8eab11 176Skip lines: $skip
bae153e5 177Max # of runs: $maxf
3405bb49 178----------------------------------------------------------------------
179EOF
180
9a684059 181# --- Lock -----------------------------------------------------------
182lock=${top}/${dest}/.lock
183if test -f $lock ; then
184 echo "Another QA process is already running:" > /dev/stderr
185 echo "Content of ${top}/${dest}/.lock:" > /dev/stderr
186 cat $lock > /dev/stderr
187 trap - EXIT
188 exit 1
189fi
190
191now=`date`
192cat <<EOF > $lock
193Process: $$
194User: $USER
195Start: $now
196EOF
197
198
2dbde04b 199# --- Download the files ---------------------------------------------
3405bb49 200if test $nodw -lt 1 ; then
201 mess "Running getQAResults.sh $opts -d $top -n "
bae153e5 202 getQAResults.sh $opts -d $top -T -v -v -i -m $maxf
5e8eab11 203else
204 mess "Not downloading"
3405bb49 205fi
2dbde04b 206
207# --- Now run the QA code -------------------------------------------
9a684059 208
5e8eab11 209mess "Now running code"
9a684059 210enable_trap
2dbde04b 211savdir=`pwd`
9a684059 212mess "Change directory to $top/$dest"
2dbde04b 213cd $top/${dest}
dc8aa359 214
9a684059 215disable_trap
216trap - ERR
217trap -p ERR
5e8eab11 218mess "List of trend_<x>.html files"
5e8eab11 219idx=`ls trend_*_*.html 2>/dev/null`
5e8eab11 220mess "Removing indeces"
dc8aa359 221rm -f index.html
222for i in $idx ; do
223 if test -f $i ; then rm -f $i ; fi
224done
225
3405bb49 226what=3
5e8eab11 227if test $notr -gt 0 ; then let what=$what^0x2 ; fi
228if test $norn -gt 0 ; then let what=$what^0x1 ; fi
dc8aa359 229
bd6f5206 230scr=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/RunQA.C
3405bb49 231mess "Running root -l -b -q ${scr}\(\".\",1,-1,$what\)"
9a684059 232
233enable_trap
3405bb49 234root -l -b -q ${scr}\(\".\",1,-1,$what\)
9a684059 235trap - ERR
236disable_trap
dc8aa359 237
3405bb49 238idx=`ls trend_*_*.html 2>/dev/null`
dc8aa359 239rm -f index.html
3405bb49 240for i in $idx ; do
241 echo "making index.html point to $i"
9a684059 242 cat $i | \
243 sed -e "s,index.html,../index.html," \
244 -e "s,!--JOBID--,a target='_blank' href='${jobUrl}${jobid}'>Job</a," \
245 > index.html
dc8aa359 246 cp index.html $i
3405bb49 247done
9a684059 248if test ! -f index.html ; then
249 echo "No index file found"
250 exit 1
251fi
3405bb49 252chmod g+rw index.html
dc8aa359 253chmod g+rw . > /dev/null 2>&1
254
9a684059 255style=
bd6f5206 256if test -f $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/style.css ; then
257 style=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/style.css
9a684059 258elif test -f $savdir/style.css ; then
259 style=$savdir/style.css
260fi
261
262if test x$style != x ; then
dc8aa359 263 rm -f style.css
9a684059 264 cp $style .
dc8aa359 265 chmod g+rw style.css
3405bb49 266fi
2dbde04b 267
268cat <<EOF
269
270Finished running QA for jobid $jobid.
271Output is stored in $top/${dest}
3405bb49 272
2dbde04b 273EOF
274
3405bb49 275# --- Make index.html ------------------------------------------------
276cd ..
0fe5b1b4 277date=`date`
3405bb49 278period=`pwd`
279period=`basename $period`
dc8aa359 280rm -f index.html
3405bb49 281cat <<EOF > index.html
282<html>
283<head>
284<title>$period</title>
285<LINK REL="stylesheet" href="style.css">
286</head>
287<body>
288<h1>$period</h1>
289<ul>
290EOF
291for i in * ; do
292 if test ! -d $i ; then continue ; fi
293 echo "<li><a href='$i'>$i</a></li>" >> index.html
294done
295cat <<EOF >> index.html
296</ul>
9a684059 297<div class='jobid'>
298
299</div>
300<div class='back'>
301 <a href="../">Back</a>
302</div>
0fe5b1b4 303<div class='change'>
9a684059 304 Last update: $date
0fe5b1b4 305</div>
3405bb49 306</body>
307</html>
308EOF
309chmod g+rw index.html
dc8aa359 310chmod g+rw . > /dev/null 2>&1
9a684059 311if test x$style != x ; then
dc8aa359 312 rm -f style.css
9a684059 313 cp $style .
e92d0953 314 chmod g+rw style.css
3405bb49 315fi
316
317# --- Make index.html ------------------------------------------------
318cd ..
dc8aa359 319rm -f index.html
3405bb49 320cat <<EOF >index.html
321<html>
322<head>
323<title>QA for the FMD</title>
324<LINK REL="stylesheet" href="style.css">
325</head>
326<body>
327<h1>QA for the FMD</h1>
328<p>
329For more information, see <a href='https://twiki.cern.ch/twiki/bin/viewauth/ALICE/FMDQA'>TWiki pages</a>
330</p>
331<ul>
332EOF
333for i in * ; do
334 if test ! -d $i ; then continue ; fi
335 echo "<li><a href='$i'>$i</a></li>" >> index.html
336done
337cat <<EOF >> index.html
338</ul>
0fe5b1b4 339<div class='change'>
340Last update: $date
341</div>
3405bb49 342</body>
343</html>
344EOF
345chmod g+rw index.html
dc8aa359 346chmod g+rw . > /dev/null 2>&1
9a684059 347if test x$style != x ; then
dc8aa359 348 rm -f style.css
9a684059 349 cp $style .
e92d0953 350 chmod g+rw style.css
3405bb49 351fi
352
353cd $savdir
9a684059 354rm -f $lock
3405bb49 355
2dbde04b 356#
357# EOF
358#
359
360
361
362