]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FORWARD/analysis2/qa/getQAResults.sh
Major overhaul of the QA code.
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / qa / getQAResults.sh
index 40b412aec91da9b1d4205633997c77557f77c807..fa319001be09f45a03feb06e606b89f2f38415ab 100755 (executable)
@@ -1,18 +1,14 @@
 #!/bin/bash
-
-# --------------------------------------------------------------------
-uid=`id -u`
-genv_file=/tmp/gclient_env_${uid}
-
-if test ! -f ${genv_file} ; then 
-    echo "No such file: ${genv_file}, please do alien-token-init" >/dev/stderr
-    exit 1
-fi
-alien-token-info | grep -q "Token is still valid"
-if test $? -ne 0 ; then 
-    echo "Token not valid, please re-new" > /dev/stderr 
-    exit 1
-fi
+#
+# @file   getQAResults.sh
+# @author Christian Holm Christensen <cholm@nbi.dk>
+# @date   Thu Nov 17 11:47:14 2011
+# 
+# @brief Retrieve trending.root/QAResults.root files from AliEn for a
+# given producton as specified by the command line options 
+# 
+# @ingroup pwg2_forward_qa_scripts
+#
 
 # --------------------------------------------------------------------
 verb=0
@@ -33,11 +29,15 @@ Options:
        -h,--help                     This help 
        -v,--verbose                  Be verbose
        -p,--production  IDENTIFIER   Production identifier [$prod]
-       -y,--year        YEAR         Year of production [$year]
        -P,--pass        NUMBER       Reconstruction pass number [$pass]
+       -Q,--pre-pass    STRING       Prefix to pass identifier [${prep}]
+       -R,--post-pass   STRING       Postfix to pass identifier [$post]
+       -y,--year        YEAR         Year of production [$year]
        -d,--destination DIRECTORY    Directory to store result in [$dest] 
        -r,--run         NUMBER       Run number [$runn]
        -q,--qa          NUMBER       QA number 
+       -f,--file        NAME         File to get [$file]
+       -T,--trending                 Get trending.root file 
        -a,--archives                 Get ZIP archives 
        -n,--no-action                Run dry (do not copy files)
 
@@ -54,6 +54,7 @@ check_file()
     cat <<EOF > ${scr}.C  
 void ${scr}() 
 {
+  int ret = 0;
   gSystem->Load("libANALYSIS");
   gSystem->Load("libANALYSISalice");
   gSystem->Load("libTENDER");
@@ -64,20 +65,18 @@ void ${scr}()
   if (!file) { 
     Error("${scr}", "No such file ${inp}");
     exit(1);
-    return false;
   }
   TObject* forward1 = file->Get("Forward");
   if (!forward1) {
     Error("${scr}", "No Forward object found in ${inp}");
-    exit(2);
-    ret = false;
+    ret |= 2;
   } 
   TObject* forward2 = file->Get("ForwardResults");
   if (!forward2) {
     Error("${scr}", "No ForwardResults object found in ${inp}");
-    exit(4);
+    ret |= 4;
   } 
-  exit(0);
+  exit(ret);
 }
 EOF
     # cat ${scr}.C 
@@ -90,15 +89,17 @@ EOF
 }
 
 # --------------------------------------------------------------------
-year=
-prod=
-pass=1
-qual=
+year=""
+prod=""
+pass=-1
+prep=""
+post=""
 dest=.
 runn=0
 qano=0
 noac=0
 arch=0
+file=QAresults.root 
 
 while test $# -gt 0 ; do 
     case $1 in 
@@ -106,18 +107,37 @@ while test $# -gt 0 ; do
        -v|--verbose)     let verb=$verb+1  ;; 
        -p|--production)  prod=$2 ; shift ;; 
        -P|--pass)        pass=$2 ; shift ;; 
-       -Q|--prepass)     qual=$2 ; shift ;; 
+       -Q|--prepass)     prep=$2 ; shift ;; 
+       -R|--postpass)    post=$2 ; shift ;; 
        -y|--year)        year=$2 ; shift ;; 
        -d|--destination) dest=$2 ; shift ;; 
        -r|--run)         runn=$2 ; shift ;; 
        -q|--qa)          qano=$2 ; shift ;; 
-       -n|--no-action)   noac=1  ;; 
+       -f|--file)        file=$2 ; shift ;; 
+       -T|--trending)    file=trending.root ; shift ;; 
        -a|--archives)    arch=1  ;; 
+       -n|--no-action)   noac=1  ;; 
        *) echo "$0: Unknown option $1" > /dev/stderr ; exit 2 ;; 
     esac
     shift
 done
 
+# --------------------------------------------------------------------
+uid=`id -u`
+genv_file=/tmp/gclient_env_${uid}
+
+if test ! -f ${genv_file} ; then 
+    echo "No such file: ${genv_file}, please do alien-token-init" >/dev/stderr
+    exit 1
+fi
+. ${genv_file}
+alien-token-info | grep -q "Token is still valid"
+if test $? -ne 0 ; then 
+    echo "Token not valid, please re-new" > /dev/stderr 
+    exit 1
+fi
+
+
 # --------------------------------------------------------------------
 if test "x$prod" = "x" ; then 
     echo "No production identifier given" > /dev/stderr 
@@ -131,40 +151,70 @@ if test "x$year" = "x" ; then
        exit 2
     fi
 fi
+lett=`echo $prod | sed -e "s/LHC${year}\(.\).*/\1/"`
+suff=`echo $prod | sed -e "s/LHC${year}${lett}//"`
 
 redir="/dev/null"
-if test $verb -gt 1 ; then redir1=/dev/stderr ; fi
+if test $verb -gt 1 ; then redir=/dev/stderr ; fi
 
 # --------------------------------------------------------------------
-path=/alice/data/20${year}/${prod}/
-store=${dest}/${prod}/${qual}pass${pass}
-search="ESDs/${qual}pass${pass}/"
+if test "x$post" != "x" ; then 
+    case $post in 
+       _*) ;; 
+       *) post="_${post}" ;; 
+    esac
+fi
+if test ${pass} -ge 0 ; then 
+    paid=pass${pass} 
+fi
+datd=data
+esdd=ESDs/
+if test "x${suff}" != "x" ; then 
+    datd=sim
+    esdd=
+fi
+path=/alice/${datd}/20${year}/${prod}/
+store=${dest}/${prod}/${prep}${paid}${post}
+search="${esdd}${prep}${paid}${post}"
 if test $runn -gt 0 ; then 
-    path=`printf "${path}%09d/ESDs/${qual}pass${pass}/" $runn` 
+    path=`printf "${path}%09d/ESDs/${prep}${paid}${pass}${post}/" $runn` 
     store=`printf "${store}/%09d" $runn` 
     search=
 fi
 if test $qano -gt 0 ; then 
-    path=`printf "%sQA%02d/" $path $qano` 
+    if test $runn -gt 0 ; then 
+       path=`printf "%sQA%02d/" $path $qano` 
+    else
+       if test "x$search" != "x" ; then search=${search}/ ; fi
+       search=${search}QA`printf %02d ${qano}` 
+    fi
 fi
 if test $arch -gt 0 ; then 
-    search="${search}QA_archive.zip"
-else
-    search="${search}QAresults.root"
+    file=QA_archive.zip
 fi
+base=`basename $file .root`
+if test "x$search" != "x" ; then search=${search}/ ; fi
+search="${search}${file}"
 
+# --------------------------------------------------------------------
 cat <<EOF
 Settings:
 
        Production:             $prod
        Year:                   $year
+       Letter:                 $lett
+       Suffix:                 $suff
        Pass:                   $pass
-       Pass qualifier:         $qual
+       Pass prefix:            $prep
+       Pass postfix:           $post
+       File:                   $file
        Path:                   $path
        Destination:            $dest
        Store:                  $store
        Run number:             $runn
        Search string:          $search
+       Verbosity:              $verb
+       Redirection:            $redir
 EOF
     
 # --------------------------------------------------------------------
@@ -179,21 +229,22 @@ for i in $files ; do
     if test $runn -gt 0 ; then 
        r=`echo $b | sed -e "s,[0-9]*${runn}\([0-9.]*\)/.*,\1," | tr '.' '_'`
        if test $arch -lt 1 ; then 
-           o=${store}/QAresults_${r}.zip
+           o=${store}/${base}_${r}.root
        else
            d=${store}/${r}
            mkdir -p $d
-           o=${d}/QAarchive.zip 
+           o=${d}/${file}
        fi
     else 
        r=`echo $b | sed -e "s,/.*,,"` 
-       o=${store}/QAresults_${r}.root
+       o=${store}/${base}_${r}.root
     fi
     runs="$runs $r" 
     mess "$i -> $o"
     if test $noac -lt 1 && test ! -f $o ; then 
        mess "alien_cp alien:${i} file:${o}"
        alien_cp alien:${i} file:${o} > ${redir} 2>&1 
+       if test -f $o ; then chmod g+rw ${o} ; fi
     fi
     if test $noac -lt 1 && test $arch -lt 1  ; then check_file $o ; fi
     if test $noac -lt 1 && test $arch -gt 0 ; then 
@@ -208,4 +259,4 @@ mess "Got a total of $j files for runs $runs"
 # EOF
 #
 
-    
\ No newline at end of file
+