]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FORWARD/analysis2/qa/getQAResults.sh
Minor things
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / qa / getQAResults.sh
CommitLineData
9b2f2e39 1#!/bin/bash
2
9b2f2e39 3# --------------------------------------------------------------------
4verb=0
5
6mess()
7{
8 if test $verb -lt 1 ; then return ; fi
9 echo $@
10}
11
12# --------------------------------------------------------------------
13usage()
14{
15 cat <<EOF
16Usage: $0 -p PRODUCTION [OPTIONS]
17
18Options:
19 -h,--help This help
20 -v,--verbose Be verbose
21 -p,--production IDENTIFIER Production identifier [$prod]
9b2f2e39 22 -P,--pass NUMBER Reconstruction pass number [$pass]
871a9ac1 23 -Q,--pre-pass STRING Prefix to pass identifier [${prep}]
24 -R,--post-pass STRING Postfix to pass identifier [$post]
0151a6c6 25 -y,--year YEAR Year of production [$year]
9b2f2e39 26 -d,--destination DIRECTORY Directory to store result in [$dest]
27 -r,--run NUMBER Run number [$runn]
28 -q,--qa NUMBER QA number
0151a6c6 29 -f,--file NAME File to get [$file]
30 -T,--trending Get trending.root file
9b2f2e39 31 -a,--archives Get ZIP archives
32 -n,--no-action Run dry (do not copy files)
33
34If run number is set, get the parts of next-to-last merge of that run only.
35
36EOF
37}
38
39# --------------------------------------------------------------------
40check_file()
41{
42 inp=$1
43 scr=`mktemp -u Check_XXXXXXXX`
44 cat <<EOF > ${scr}.C
45void ${scr}()
46{
871a9ac1 47 int ret = 0;
9b2f2e39 48 gSystem->Load("libANALYSIS");
49 gSystem->Load("libANALYSISalice");
50 gSystem->Load("libTENDER");
51 // gSystem->Load("libTENDERSupplies");
52 gSystem->Load("libPWG1");
53 gSystem->Load("libPWG3base");
54 TFile* file = TFile::Open("${inp}", "READ");
55 if (!file) {
56 Error("${scr}", "No such file ${inp}");
57 exit(1);
9b2f2e39 58 }
59 TObject* forward1 = file->Get("Forward");
60 if (!forward1) {
61 Error("${scr}", "No Forward object found in ${inp}");
871a9ac1 62 ret |= 2;
9b2f2e39 63 }
64 TObject* forward2 = file->Get("ForwardResults");
65 if (!forward2) {
66 Error("${scr}", "No ForwardResults object found in ${inp}");
871a9ac1 67 ret |= 4;
9b2f2e39 68 }
871a9ac1 69 exit(ret);
9b2f2e39 70}
71EOF
72 # cat ${scr}.C
73 mess -n "aliroot -l -b -q ${scr}.C "
74 aliroot -l -b -q ${scr}.C > /dev/null 2>&1
75 ret=$?
76 mess "-> $ret (0: good, 1: no file, 2: no Forward, 4: no ForwardResults"
77 rm -f ${scr}.C
78 return $ret
79}
80
81# --------------------------------------------------------------------
871a9ac1 82year=""
83prod=""
84pass=-1
85prep=""
86post=""
9b2f2e39 87dest=.
88runn=0
89qano=0
90noac=0
91arch=0
871a9ac1 92file=QAresults.root
9b2f2e39 93
94while test $# -gt 0 ; do
95 case $1 in
96 -h|--help) usage ; exit 0 ;;
97 -v|--verbose) let verb=$verb+1 ;;
98 -p|--production) prod=$2 ; shift ;;
99 -P|--pass) pass=$2 ; shift ;;
871a9ac1 100 -Q|--prepass) prep=$2 ; shift ;;
101 -R|--postpass) post=$2 ; shift ;;
9b2f2e39 102 -y|--year) year=$2 ; shift ;;
103 -d|--destination) dest=$2 ; shift ;;
104 -r|--run) runn=$2 ; shift ;;
105 -q|--qa) qano=$2 ; shift ;;
871a9ac1 106 -f|--file) file=$2 ; shift ;;
0151a6c6 107 -T|--trending) file=trending.root ; shift ;;
9b2f2e39 108 -a|--archives) arch=1 ;;
0151a6c6 109 -n|--no-action) noac=1 ;;
9b2f2e39 110 *) echo "$0: Unknown option $1" > /dev/stderr ; exit 2 ;;
111 esac
112 shift
113done
114
871a9ac1 115# --------------------------------------------------------------------
116uid=`id -u`
117genv_file=/tmp/gclient_env_${uid}
118
119if test ! -f ${genv_file} ; then
120 echo "No such file: ${genv_file}, please do alien-token-init" >/dev/stderr
121 exit 1
122fi
123. ${genv_file}
124alien-token-info | grep -q "Token is still valid"
125if test $? -ne 0 ; then
126 echo "Token not valid, please re-new" > /dev/stderr
127 exit 1
128fi
129
130
9b2f2e39 131# --------------------------------------------------------------------
132if test "x$prod" = "x" ; then
133 echo "No production identifier given" > /dev/stderr
134 exit 2
135fi
136
137if test "x$year" = "x" ; then
138 year=`echo $prod | sed -e 's/LHC\(..\).*/\1/'`
139 if test "x$year" = "x" ; then
140 echo "Couldn't get year from production identifier $prod" > /dev/stderr
141 exit 2
142 fi
143fi
871a9ac1 144lett=`echo $prod | sed -e "s/LHC${year}\(.\).*/\1/"`
145suff=`echo $prod | sed -e "s/LHC${year}${lett}//"`
9b2f2e39 146
147redir="/dev/null"
871a9ac1 148if test $verb -gt 1 ; then redir=/dev/stderr ; fi
9b2f2e39 149
150# --------------------------------------------------------------------
871a9ac1 151if test "x$post" != "x" ; then
152 case $post in
153 _*) ;;
154 *) post="_${post}" ;;
155 esac
156fi
157if test ${pass} -ge 0 ; then
158 paid=pass${pass}
159fi
160datd=data
161esdd=ESDs/
162if test "x${suff}" != "x" ; then
163 datd=sim
164 esdd=
165fi
166path=/alice/${datd}/20${year}/${prod}/
167store=${dest}/${prod}/${prep}${paid}${post}
168search="${esdd}${prep}${paid}${post}"
9b2f2e39 169if test $runn -gt 0 ; then
871a9ac1 170 path=`printf "${path}%09d/ESDs/${prep}${paid}${pass}${post}/" $runn`
9b2f2e39 171 store=`printf "${store}/%09d" $runn`
172 search=
173fi
174if test $qano -gt 0 ; then
871a9ac1 175 if test $runn -gt 0 ; then
176 path=`printf "%sQA%02d/" $path $qano`
177 else
178 if test "x$search" != "x" ; then search=${search}/ ; fi
0151a6c6 179 search=${search}QA`printf %02d ${qano}`
871a9ac1 180 fi
9b2f2e39 181fi
182if test $arch -gt 0 ; then
871a9ac1 183 file=QA_archive.zip
9b2f2e39 184fi
871a9ac1 185base=`basename $file .root`
186if test "x$search" != "x" ; then search=${search}/ ; fi
187search="${search}${file}"
9b2f2e39 188
871a9ac1 189# --------------------------------------------------------------------
9b2f2e39 190cat <<EOF
191Settings:
192
193 Production: $prod
194 Year: $year
871a9ac1 195 Letter: $lett
196 Suffix: $suff
9b2f2e39 197 Pass: $pass
871a9ac1 198 Pass prefix: $prep
199 Pass postfix: $post
200 File: $file
9b2f2e39 201 Path: $path
202 Destination: $dest
203 Store: $store
204 Run number: $runn
205 Search string: $search
871a9ac1 206 Verbosity: $verb
207 Redirection: $redir
9b2f2e39 208EOF
209
210# --------------------------------------------------------------------
211mkdir -p ${store}
212mess "alien_find ${path} ${search}"
213files=`alien_find ${path} ${search} | grep -v "files found" 2> ${redir}`
214j=0
215runs=
216for i in $files ; do
217 b=`echo $i | sed -e "s,${path},,"`
218 d=
219 if test $runn -gt 0 ; then
220 r=`echo $b | sed -e "s,[0-9]*${runn}\([0-9.]*\)/.*,\1," | tr '.' '_'`
221 if test $arch -lt 1 ; then
871a9ac1 222 o=${store}/${base}_${r}.root
9b2f2e39 223 else
224 d=${store}/${r}
225 mkdir -p $d
871a9ac1 226 o=${d}/${file}
9b2f2e39 227 fi
228 else
229 r=`echo $b | sed -e "s,/.*,,"`
871a9ac1 230 o=${store}/${base}_${r}.root
9b2f2e39 231 fi
232 runs="$runs $r"
233 mess "$i -> $o"
234 if test $noac -lt 1 && test ! -f $o ; then
235 mess "alien_cp alien:${i} file:${o}"
236 alien_cp alien:${i} file:${o} > ${redir} 2>&1
237 fi
238 if test $noac -lt 1 && test $arch -lt 1 ; then check_file $o ; fi
239 if test $noac -lt 1 && test $arch -gt 0 ; then
240 (cd ${d} && unzip QAarchive.zip) > $redir 2>&1
241 fi
242 let j=$j+1
243done
244mess "Got a total of $j files for runs $runs"
245
246# --------------------------------------------------------------------
247#
248# EOF
249#
250
0151a6c6 251