3 # @file getQAResults.sh
4 # @author Christian Holm Christensen <cholm@nbi.dk>
5 # @date Thu Nov 17 11:47:14 2011
7 # @brief Retrieve trending.root/QAResults.root files from AliEn for a
8 # given producton as specified by the command line options
10 # @ingroup pwg2_forward_qa_scripts
13 # --------------------------------------------------------------------
18 if test $verb -lt 1 ; then return ; fi
22 # --------------------------------------------------------------------
26 Usage: $0 -p PRODUCTION [OPTIONS]
30 -v,--verbose Be verbose
31 -p,--production IDENTIFIER Production identifier [$prod]
32 -P,--pass NUMBER Reconstruction pass number [$pass]
33 -Q,--pre-pass STRING Prefix to pass identifier [${prep}]
34 -R,--post-pass STRING Postfix to pass identifier [$post]
35 -y,--year YEAR Year of production [$year]
36 -d,--destination DIRECTORY Directory to store result in [$dest]
37 -r,--run NUMBER Run number [$runn]
38 -q,--qa NUMBER QA number
39 -f,--file NAME File to get [$file]
40 -m,--max NUMBER Maximum number of files to get [$maxf]
41 -T,--trending Get trending.root file
42 -a,--archives Get ZIP archives
43 -n,--no-action Run dry (do not copy files)
44 -i,--no-check Do not check files [$docheck]
46 If run number is set, get the parts of next-to-last merge of that run only.
51 # --------------------------------------------------------------------
55 if test $docheck -lt 1 ; then return 0; fi
57 scr=`mktemp -u Check_XXXXXXXX`
62 gSystem->Load("libANALYSIS");
63 gSystem->Load("libANALYSISalice");
64 gSystem->Load("libTENDER");
65 // gSystem->Load("libTENDERSupplies");
66 gSystem->Load("libPWGPP");
67 gSystem->Load("libPWG3base");
68 TFile* file = TFile::Open("${inp}", "READ");
70 Error("${scr}", "No such file ${inp}");
73 TObject* forward1 = file->Get("Forward");
75 Error("${scr}", "No Forward object found in ${inp}");
78 TObject* forward2 = file->Get("ForwardResults");
80 Error("${scr}", "No ForwardResults object found in ${inp}");
87 mess -n "aliroot -l -b -q ${scr}.C "
88 aliroot -l -b -q ${scr}.C > /dev/null 2>&1
90 mess "-> $ret (0: good, 1: no file, 2: no Forward, 4: no ForwardResults"
95 # --------------------------------------------------------------------
109 while test $# -gt 0 ; do
111 -h|--help) usage ; exit 0 ;;
112 -v|--verbose) let verb=$verb+1 ;;
113 -p|--production) prod=$2 ; shift ;;
114 -P|--pass) pass=$2 ; shift ;;
115 -Q|--prepass) prep=$2 ; shift ;;
116 -R|--postpass) post=$2 ; shift ;;
117 -y|--year) year=$2 ; shift ;;
118 -d|--destination) dest=$2 ; shift ;;
119 -r|--run) runn=$2 ; shift ;;
120 -q|--qa) qano=$2 ; shift ;;
121 -f|--file) file=$2 ; shift ;;
122 -m|--max) maxf=$2 ; shift ;;
123 -T|--trending) file=trending.root ; shift ;;
124 -a|--archives) arch=1 ;;
125 -n|--no-action) noac=1 ;;
126 -i|--no-check) docheck=0 ;;
127 *) echo "$0: Unknown option $1" > /dev/stderr ; exit 2 ;;
132 # --------------------------------------------------------------------
134 genv_file=/tmp/gclient_env_${uid}
136 if test ! -f ${genv_file} ; then
137 echo "No such file: ${genv_file}, please do alien-token-init" >/dev/stderr
141 alien-token-info | grep -q "Token is still valid"
142 if test $? -ne 0 ; then
143 echo "Token not valid, please re-new" > /dev/stderr
148 # --------------------------------------------------------------------
149 if test "x$prod" = "x" ; then
150 echo "No production identifier given" > /dev/stderr
154 if test "x$year" = "x" ; then
155 year=`echo $prod | sed -e 's/LHC\(..\).*/\1/'`
156 if test "x$year" = "x" ; then
157 echo "Couldn't get year from production identifier $prod" > /dev/stderr
161 lett=`echo $prod | sed -e "s/LHC${year}\(.\).*/\1/"`
162 suff=`echo $prod | sed -e "s/LHC${year}${lett}//"`
165 if test $verb -gt 1 ; then redir=/dev/stderr ; fi
167 # --------------------------------------------------------------------
168 if test "x$post" != "x" ; then
171 *) post="_${post}" ;;
174 if test ${pass} -ge 0 ; then
179 dprod=LHC${year}${lett}
183 *) datd=sim ; esdd= ; dprod=${dprod}${suff};;
185 path=/alice/${datd}/20${year}/${prod}/
186 store=${dest}/${dprod}/${prep}${paid}${post}
187 search="${esdd}${prep}${paid}${post}"
188 if test $runn -gt 0 ; then
189 path=`printf "${path}%09d/ESDs/${prep}${paid}${pass}${post}/" $runn`
190 store=`printf "${store}/%09d" $runn`
193 if test $qano -gt 0 ; then
194 if test $runn -gt 0 ; then
195 path=`printf "%sQA%02d/" $path $qano`
197 if test "x$search" != "x" ; then search=${search}/ ; fi
198 search=${search}QA`printf %02d ${qano}`
201 if test $arch -gt 0 ; then
204 base=`basename $file .root`
205 if test "x$search" != "x" ; then search=${search}/ ; fi
206 search="${search}${file}"
208 # --------------------------------------------------------------------
224 Search string: $search
229 # --------------------------------------------------------------------
231 mess "Getting list of files from AliEn - can take minutes - be patient"
232 mess "alien_find ${path} ${search}"
233 files=`alien_find ${path} ${search} | grep -v "files found" 2> ${redir}`
238 mess "Got a list of $tot files"
239 if test $maxf -gt 0 && test $maxf -lt $tot ; then
240 mess "Number of files to get limited to $maxf"
246 if test $maxf -gt 0 && test $j -ge $maxf ; then
249 b=`echo $i | sed -e "s,${path},,"`
251 if test $runn -gt 0 ; then
252 r=`echo $b | sed -e "s,[0-9]*${runn}\([0-9.]*\)/.*,\1," | tr '.' '_'`
253 if test $arch -lt 1 ; then
254 o=${store}/${base}_${r}.root
261 r=`echo $b | sed -e "s,/.*,,"`
262 o=${store}/${base}_${r}.root
265 printf "%3d/%3d: " $j $tot
267 if test $noac -lt 1 && test ! -f $o ; then
268 # mess "alien_cp alien:${i} file:${o}"
270 alien_cp alien:${i} file:${o} > ${redir} 2>&1
271 if test -f $o ; then chmod g+rw ${o} ; fi
275 if test $noac -lt 1 && test $arch -lt 1 ; then check_file $o ; fi
276 if test $noac -lt 1 && test $arch -gt 0 ; then
277 (cd ${d} && unzip QAarchive.zip) > $redir 2>&1
281 mess "Got a total of $j files for runs $runs"
283 # --------------------------------------------------------------------