]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/FORWARD/analysis2/qa/RunQAMT.sh
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / qa / RunQAMT.sh
index 038e2c6e79223d95e58448cfc6f559b518214cdf..a438d62a558d500532483cc4af9560534dd68bd1 100755 (executable)
@@ -1,52 +1,19 @@
 #!/bin/bash
 #
-# This script runs the Forward QA for the specified production number
+# This script runs the Forwardqq QA for the specified production number
 #
 # The scripts downloads and runs the single run QA in parallel 
 #
 
 # --- Some aux files -------------------------------------------------
-style=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/style.css 
-favicon=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/fmd_favicon.png
-logo=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/fmd_logo.png
-script=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/script.js
-topmk=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/makeIndex.sh
-
-# --- Help output ----------------------------------------------
-usage()
-{
-    cat <<EOF
-Usage: $0 [OPTIONS] -j [JOBID]
-       $0 [OPTIONS] -p PRODUCTION -P PASS 
-
-Options:
-       -h,--help                  This help 
-       -j,--jobid      NUMBER     The master job id of the production [$jobid]
-       -v,--verbose               Increase verbosity [$verb]
-       -m,--max-files  NUMBER     Max number of files to get [$maxf]
-       -M,--max-jobs   NUMBER     Max number of consequtive jobs [$maxjobs]
-       -t,--top        DIRECTORY  Output directory [$top]
-       -R,--also-results          Also get QAresults.root for each run
-       -Q,--qa-number  NUMBER     Custom QA id [$qanumber]
-       -p,--production IDENTIFIER Production identifier [$prodfull]
-       -P,--pass       IDENTIFIER Pass identifier [$passfull]
-       -l,--log-file              Log file output [$redir]
-       -b,--barrel     MODE       Fetch barrel data  [$barrel]
-       -f,--force                 Force re-run analysis [$force]
-       -V,--variance              Errors=variance (not min/max) [$variance]
-        -L,--local                 Local trending_<X>.root files [$from_local]
-       -d,--directory  DIR        Search custom AliEn directory [$path]
-
-Note the option -j and the options -p and -P are mutually exclusive,
-The option -Q is only used if the options -p and -P are given.
-Production identifiers are of the form LHC11h, LHC11h3, or LHC11h_2. 
-Pass identifers are of the form pass2, pass1_HLT, or cpass1.  
-If barrel mode>0, then do not assume ESD directory.  
-If barrel mode>1, then get trending_barrel.root and QAresults_barrel.root
-Option -d is for hand-made QA passes. 
-If optiond -d is not specified then official QA passes are assumed.
-EOF
-}
+if test "X$QA_FWD" = "X" ; then 
+    QA_FWD=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa
+fi 
+style=${QA_FWD}/style.css 
+favicon=${QA_FWD}/fmd_favicon.png
+logo=${QA_FWD}/fmd_logo.png
+script=${QA_FWD}/script.js
+topmk=${QA_FWD}/makeIndex.sh
 
 # --- Check AliEn token ----------------------------------------------
 check_token()
@@ -69,11 +36,37 @@ check_token()
 
 # --- Diagnostics output ---------------------------------------------
 verb=0
+print() { 
+    local col=$1 ; shift 
+    local lvl=$1 ; shift 
+    local opt=
+    if test $lvl -gt $verb; then return ; fi 
+    case $1 in 
+       -*) opt=$1 ; shift ;; 
+    esac
+    echo -e ${opt} "\e[${col}m$*\e[0m"
+    # echo -e ${opt} "\e[${col}m$*\e[0m"
+}
 mess()
 {
-    if test $1 -gt $verb ; then return ; fi 
-    shift
-    echo $*
+    print 95 $@ 
+}
+
+err() 
+{
+    echo -e "\e[1mError: \e[91m$*\e[0m" > /dev/stderr 
+}
+warn()
+{
+    echo -e "\e[1mWarning: \e[93m$*\e[0m" > /dev/stderr 
+}
+info() 
+{
+    print 96 0 $@ 
+}
+ok() 
+{
+    print 92 0 "OK"
 }
 
 # --- Handling of exit -----------------------------------------------
@@ -93,7 +86,7 @@ trap handle_exit EXIT
 last=
 handle_err()
 {
-    echo "Error: $last" 
+    err "$last"
     exit 1
 }
 enable_trap()
@@ -112,18 +105,18 @@ check_lock()
     lock=$loc/.lock
 
     if test -f $lock ; then 
-       echo "Another QA process is already running:" > /dev/stderr 
-       echo "Content of ${lock}:" > /dev/stderr 
+       err "Another QA process is already running:"
+       err "Content of ${lock}:"
        cat $lock > /dev/stderr 
        trap - EXIT
-    exit 1
+       exit 1
+    fi 
     local now=`date` 
-    cat <<EOF > $lock
-Process: $$
-User:    $USER
-Start:   $now
-EOF
-    fi
+    cat <<-EOF > $lock
+       Process: $$
+       User:    $USER
+       Start:   $now
+       EOF
 }
 
 # --- Parse production information -----------------------------------
@@ -155,56 +148,6 @@ prodpost=
 remainder=
 qanumber=0
 barrel=0
-get_parts()
-{
-    mess 1 "Parsing information from job $@" 
-    year=$1 ; shift 
-    prodfull=$1 ; shift 
-    local lrunn=$1 ; shift
-    local ltype=$1 ; shift 
-    passfull=$1 ; shift 
-    remainder=$1 
-
-    mess 10 "year=$year" 
-    mess 10 "prodfull=$prodfull" 
-    mess 10 "lrunn=$lrunn" 
-    mess 10 "ltype=$ltype" 
-    mess 10 "passfull=$passfull" 
-    mess 10 "remainder=$remainder"
-
-    if test "x$passfull" = "x" ; then 
-       remainder=
-       passfull=$ltype 
-    fi
-    case x$passfull in 
-       *pass*) ;; 
-       *) remainder=$passfull 
-           passfull= 
-           ;;
-    esac
-    parse_pass 
-    parse_prod
-
-    case x$remainder in 
-       xQA*) qanumber=`echo $remainder | sed 's/QA//'`  ;; 
-       *) ;; 
-    esac
-
-}
-# --- Get the index for information ----------------------------------
-skip=0
-jobu="http://alimonitor.cern.ch/prod/jobs.jsp?t="
-jobid=
-get_job() 
-{ 
-    mess 1 "Getting the job information" 
-    wget -q ${jobu}${jobid} -O job.html
-    local lskip
-    let lskip=$skip+1
-    p=`grep "/catalogue/index.jsp?path" job.html | head -n $lskip | tail -n 1 | sed -e 's,.*/alice/\(data\|sim\)/\([^<]*\)<.*,\2,' | tr '/' ' '` 
-    rm -f job.html
-    get_parts $p 
-}
 
 # --- Append path element --------------------------------------------
 append_to_path()
@@ -222,6 +165,10 @@ files=
 path=
 numf=0
 from_local=0
+type=data
+passid=
+mc=0
+search=
 get_filelist()
 {
     mess 3 "Getting file list" 
@@ -235,17 +182,25 @@ get_filelist()
        file=trending_barrel.root
        other=QAresults_barrel.root
     fi
-    case x$prodpost in 
+    if test $mc -gt 0 ; then 
+       datd=sim 
+       type=sim
+       esdd= 
+    fi 
+
+    local post=${passpost}
+    case x$post in 
        x_*) ;; 
        x) ;; 
-       *)  mess 3 "Assuming simulation output"
-           datd=sim 
-           esdd= 
-           ;; 
+       *) post="_${post}" ;; 
     esac
-    
+
     local paid=
-    if echo "$passno" | grep -q -E '^[0-9]*[.]?[0-9]*$' ; then 
+    if test "x${passpre}pass${passno}${post}" != "x$passfull" ; then 
+       passpre=
+       paid=${passfull}
+       post=
+    elif echo "$passno" | grep -q -E '^[0-9]*[.]?[0-9]*$' ; then 
        if test "x$passfull" != "x" && test $passno -gt 0 ; then 
            paid=pass${passno}
        fi
@@ -254,14 +209,10 @@ get_filelist()
        passpre=
        post=
     fi
-    local post=${passpost}
-    case x$post in 
-       x_*) ;; 
-       x) ;; 
-       *) post="_${post}" ;; 
-    esac
+    passid=${paid}
+    if test $mc -gt 0 ; then passid="passMC" ; fi 
 
-    local search=
+    search=
     if test "x$path" = "x" ; then 
        # Assume official productions 
        path=/alice/${datd}/${year}/${prodfull}/
@@ -283,32 +234,36 @@ get_filelist()
 EOF
     if test $from_local -lt 1 ; then 
 
-       mess 1 "Getting list of files from AliEn - can take minutes - be patient"
+       mess 1 "Get list of files from AliEn - can take minutes - be patient"
        mess 2 "alien_find ${path} ${search}"
-       files=`alien_find ${path} ${search} | grep -v "\(files found\|AND THE\)" 2>> ${redir}` 
+       files=`alien_find ${path} ${search} | \
+         grep -v "\(files found\|AND THE\)" 2>> ${redir}` 
     else 
-       files=`ls ${top}/${store}/trending_*.root | sed 's,${top}/${store}/,,g'`
+       files=`ls ${top}/${store}/*/input.root | \
+         sed 's,${top}/${store}/,,g'`
     fi
     for i in $files ; do 
        let numf=$numf+1
     done 
     mess 1 -n "Total of $numf files ... "
+    ret=$numf
     if test $maxf -lt 0 ; then 
        mess 1 "using all" 
     else
        mess 1 "using $maxf first of these"
+       ret=$maxf
     fi
+    return $ret
 }
 
 # --- Change permissions on files ------------------------------------
 fix_perm()
 {
-    # if test ! -f $1 ; then return ; fi 
-    chmod g+rwX $1 >> /dev/null 2>&1 
-    chmod o+rX $1 >> /dev/null 2>&1 
-    # 
-    # chmod g+rwX $1 >> ${redir} 2>&1 
-    # chmod o+rX $1 >> ${redir} 2>&1 
+    local tgt=$1
+    local opt= 
+    if test -d $tgt ; then opt="-R" ; fi 
+    chmod ${opt} g+rwX $tgt >> /dev/null 2>&1 
+    chmod ${opt} o+rX $tgt >> /dev/null 2>&1 
 }
 
 # --- Check if a file is OK ------------------------------------------
@@ -317,8 +272,8 @@ check_file()
 {
     if test $docheck -lt 1 ; then return 0; fi 
     root -l -b  <<EOF >> ${redir} 2>&1 
-.L $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/CheckQAFile.C
-CheckQAFile("$1");
+.L ${QA_FWD}/CheckQAFile.C
+CheckQAFile("$1","QA");
 .q
 EOF
     local ret=$? 
@@ -332,7 +287,9 @@ analyse_file()
 {
     local dir=`dirname $1` 
     local inp=`basename $1` 
-    local out=`echo $inp | sed 's/trending_/tree_/'` 
+    local r=$2
+    local out=trending.root 
+    # `echo $inp | sed 's/trending_/tree_/'` 
     local ret=0
     mess 2 -n "Analysing $inp -> $out ... "
 
@@ -344,16 +301,21 @@ analyse_file()
        rm -f $dir/$out
     fi
 
+    
+    mess 3 "runQA.sh '$inp' '$type' '$prodyear' '$prodfull' '$passid' '$r'"
     (cd $dir 
-       root -l -b  <<EOF 
-.L RunFileQA.C
-RunFileQA("$inp", "$out", $prodyear, "$prodletter");
-.q
-EOF
-       ret=$? 
-       mess 2 " -> $ret"
-       # rm -f ${scr}.C 
-    ) 2>> $redir
+       for i in QABase QAPlotter QARing QAStructs QATrender ; do 
+           rm -f ${i}*
+           ln -s ../${i}* . 
+       done 
+       ${QA_FWD}/runQA.sh \
+           "$inp" "$type" $prodyear "$prodfull" "$passid" "$r" > runQA.log 2>&1
+       ret=$? ) 
+    if test ! -f $dir/trending.root ; then ret=1 ; fi
+    mess 2 " -> $ret"
+    if test $ret -ne 0 ; then 
+       err "Failed to analyse $1"
+    fi
     return $ret
 }
 
@@ -363,10 +325,12 @@ analyse_run()
 {
     local source=$1 ; shift 
     local store=$1 ; shift 
-    local r=$1 ; shift 
-    local o=${store}/`basename $file .root`_${r}.root 
+    local r=`echo $1 | sed 's/^0*//'` ; shift 
+    local rr=`printf %09d $r`
+    local o=${store}/${rr}/input.root
+    mkdir -p ${store}/${rr}
 
-    mess 2 -n "$source -> $o ... "
+    mess 2 -n "$source ($store) -> $o ... "
     if test -f $o && test $force -lt 2; then 
        mess 2 "exists" 
        # sleep 1
@@ -399,11 +363,11 @@ analyse_run()
     check_file ${o} 
     local ret=$? 
     case $ret in 
-       0|2) ;; 
+       0|2) ;; 
        1|3|4|5|6) return 2 ;; 
     esac
 
-    analyse_file ${o}
+    analyse_file ${o} ${r}
 
     return 0
 }
@@ -423,13 +387,19 @@ submit_runs()
 
        local r
        if test $from_local -lt 1 ; then 
-           local b=`echo $i | sed -e "s,${path},,"` 
-           r=`echo $b | sed -e "s,/.*,,"` 
+           local b=`echo $i | sed -e "s,${path}/*,,"` 
+           if test "x$search" != "x" ; then 
+               b=`echo $b | sed -s "s,/*${search},,"`
+           fi
+           r=`echo $b | sed -e "s,/.*,," | sed 's/^0*//'` 
+           # local b=`basename $(dirname $i)`
+           # r=`echo $b | sed 's/^0*//'`
        else
-           r=`basename $i .root | sed 's/trending_//'` 
+            r=`basename \`dirname $i\` | sed 's/^0*//'`
        fi
 
-       printf "%3d/%3d: %s\n" $cur $max $r 
+       local m=`printf "%3d/%3d: %s\n" $cur $max $r` 
+       info "$m"
        runs[$counter]=$r
 
        let counter=$counter+1
@@ -503,183 +473,149 @@ copy_style()
 }      
 
 # --- Run the final trending -----------------------------------------
-variance=0
+variance=1
 make_trend()
 {
     local dir=$1 
     local ret=0
-    mess 1 -n "Analysing for trend $dir ... "
+    info -n "Analysing for trend $dir ... "
     (cd $dir 
-       rm -f trend_*_*.html 
-       rm -f trend_*_*.pdf
-       rm -f trend_*_*.root
-
-       root -l -b <<EOF 
-.L RunFinalQA.C
-RunFinalQA(".", $prodyear, "$prodletter", $variance);
-.q
-EOF
-       mess 1 -n " ... "
-       # mess 3 -n "root -l -b -q ${scr}.C "
-       # root -l -b -q ${scr}.C  > /dev/null 2>&1 
-       # local ret=$? 
-       # mess 1 " -> $ret"
-       # rm -f ${scr}.C 
-
-       # do the index file 
-       local idx=`ls trend_*_*.html 2> /dev/null` 
-       for i in $idx ; do 
-           mess 1 "Making index.html point to $i" 
-           sed -e 's,index.html,../index.html,' \
-               -e "s,!--JOBID--,a target='_blank' href='${jobu}${jobid}'>Job</a," \
-               < $i > index.html 
-           cp index.html $i
-       done
-       
-       if test ! -f index.html ; then 
-           echo "No index file found" 
-           ret=1
+       mess 1 "hadd trending.root 000*/trending.root"
+       rm -f trending.root 
+       hadd -k trending.root 000*/trending.root 
+       if test $? -eq 0 && test -f trending.root ; then 
+         ${QA_FWD}/periodQA.sh trending.root 
+         ret=$?
        else 
-           fix_perm index.html 
-           fix_perm . > /dev/null 2>&1 
-       fi
-
-       copy_style
-       copy_aliroot_file $favicon
-       copy_aliroot_file $logo
-    ) 2>> $redir
+         ret=1
+        fi
+    ) >>${redir} 2>&1
+    if test $ret -ne 0 ; then 
+       err "Failed to make trending in $dir"
+    else
+       ok
+    fi
     return $ret
 }
 
-# --- Make index file ------------------------------------------------
-make_index()
+
+# --- Help output ----------------------------------------------
+usage()
 {
-    local dir=$1   ; shift  
-    local title=$1 ; shift
-    local desc=$1  ; shift 
-    mess 1 "Making index in $dir ($title)"
-    
-    (cd $dir
-       local date=`date` 
-       
-       rm -f index.html 
-
-       cat <<EOF > index.html
-<!DOCTYPE html>
-<html>
-  <head>
-    <title>$title</title>
-    <link rel='stylesheet' href='style.css'>
-    <link rel='shortcut icon' href='fmd_favicon.png' type='image/x-png'>
-  </head>
-  <body>
-    <h1><img style='width: 200px;' src='fmd_logo.png'>  &nbsp;$title</h1>
-EOF
-       if test ! "x$desc" = "x" ; then 
-           echo "<p>$desc</p>" >> index.html
-       fi
-       echo "      <ul>" >> index.html
-       for i in * ; do 
-           if test ! -d $i ; then continue ; fi 
-           echo "      <li><a href='$i'>$i</a></li>" >> index.html
-       done
-       echo "      </ul>" >> index.html 
-       if test "x$desc" = "x" ; then 
-           echo "      <div class='back'><a href='../'>Back</a></div>" \
-               >> index.html
-       fi
-       cat <<EOF >> index.html    
-    <div class='change'>Last update: $date</div>
-  </body>
-</html>
+    cat <<EOF
+Usage: $0 [OPTIONS] -p PRODUCTION [-P PASS]
+
+Options:
+  -b,--barrel       MODE       Fetch barrel data              [$barrel]
+  -d,--directory    DIR        Search custom AliEn directory  [$path]
+  -f,--force                   Force re-run analysis          [$force]
+  -h,--help                   This help 
+  -i,--no-index                Do not make index              [$index]
+  -l,--log-file                Log file output                [$redir]
+  -L,--local                   Local trending_<X>.root files  [$from_local]
+  -m,--max-files    NUMBER     Max number of files to get     [$maxf]
+  -M,--max-jobs     NUMBER     Max number of consequtive jobs [$maxjobs]
+  -p,--production   IDENTIFIER Production identifier          [$prodfull]
+  -P,--pass         IDENTIFIER Pass identifier                [$passfull]
+  -Q,--qa-number    NUMBER     Custom QA id                   [$qanumber]
+  -R,--also-results            Also get QAresults.root/run    [$also_results]
+  -t,--top          DIRECTORY  Output directory               [$top]
+  -T,--min-max                 Errors=min/max
+  -v,--verbose                Increase verbosity             [$verb]
+  -V,--variance                Errors=variance                [$variance]
+
+Production identifiers are of the form LHC11h, LHC11h3, or LHC11h_2. 
+Pass identifers are of the form pass2, pass1_HLT, or cpass1.  
+If barrel mode>0, then do not assume ESD directory.  
+If barrel mode>1, then get trending_barrel.root and QAresults_barrel.root
+Option -d is for hand-made QA passes. 
+If optiond -d is not specified then official QA passes are assumed.
 EOF
-       copy_style 
-       copy_aliroot_file $favicon
-       copy_aliroot_file $logo
-       fix_perm index.html
-       fix_perm . > /dev/null 2>&1 
-    )
 }
 
 
-# --- Pass command line options --------------------------------------
+# --- Parse command line options -------------------------------------
 redir=/dev/null
 maxf=-1
 top=.
+index=1
 while test $# -gt 0 ; do 
     case $1 in 
-       -h|--help) usage ; exit 0 ;; 
-       -v|--verbose)      let verb=$verb+1   ;; 
-       -j|--jobid)        jobid=$2           ; shift ;; 
+       -b|--barrel)       barrel=$2          ; shift ;;
+       -d|--directory)    path=$2            ; shift ;;
+       -f|--force)        let force=$force+1 ;; 
+       -h|--help)         usage              ; exit 0 ;; 
+       -i|--index)        index=1            ;; 
+       --no-index)        index=0            ;;
+       -l|--log-file)     redir=             ;; 
+       -L|--local)        from_local=1       ;;
        -m|--max-files)    maxf=$2            ; shift ;; 
        -M|--max-jobs)     maxjobs=$2         ; shift ;;
-       -t|--top)          top=$2             ; shift ;;
-       -R|--also-results) also_results=1     ;; 
+       -p|--production)   prodfull=$2        ; shift ; parse_prod ;;
+       -P|--pass)         passfull=$2        ; shift ; parse_pass ;;
        -Q|--qa-number)    qanumber=$2        ; shift ;;
-       -l|--log-file)     redir=             ;; 
-       -L|--local)        from_local=1       ;;
+       -R|--also-results) also_results=1     ;; 
+       -t|--top)          top=$2             ; shift ;;
+       -T|--min-max)      variance=0         ;; 
+       -v|--verbose)      let verb=$verb+1   ;; 
        -V|--variance)     variance=1         ;;
-       -b|--barrel)       barrel=$2          ; shift ;;
-       -f|--force)        let force=$force+1 ;; 
-       -p|--production) 
-           prodfull=$2; shift; parse_prod ; year=20${prodyear} ;;
-       -P|--pass) 
-           passfull=$2; shift; parse_pass ;;
-       -d|--directory)    path=$2              ; shift ;;
+        -C|--no-check)     docheck=0          ;;
        *) echo "$0: Unknown argument: $1" > /dev/stderr ; exit 1 ;; 
     esac
     shift
 done
-# --- Initial setup --------------------------------------------------
-# First, check we have a valid AliEn token, then retrieve the job 
-# information to parse out the location of the files we need, and 
-# finally make our output directory and check the lock 
+# === Initial setup ==================================================
+# --- Check for AliEn token ------------------------------------------
 check_token
 
-if test ! "x$jobid" = x ; then 
-    if test ! "x$prodfull" = "x" || test ! "x$passfull" = "x" ; then 
-       cat <<EOF > /dev/stderr
-Option -j ${jobid} and options -p and -P are mutually exclusive 
-EOF
-       exit 1
-    fi
-    get_job
+# --- Check settings -------------------------------------------------
+if test "x$prodfull" = "x" ; then
+    err "No production specified" 
+    exit 1
+fi 
+if test "x$prodpost" = "x" && test "x$passfull" = "x" ; then 
+    err "No pass specified for non-MC production"
+    exit 1
+elif test "x$passfull" = "x" || test "x$passfull" = "xpassMC"; then 
+    warn "No pass specified, assuming MC"
+    passfull=
+    mc=1
+fi 
+
+# --- Construct output -----------------------------------------------
+proddir=
+passdir=
+store=
+year=20${prodyear}
+if test $mc -gt 0 ; then 
+    proddir=${prodfull}
+    passdir=passMC
+    store=sim
 else 
-    if test "x$prodfull" = "x" || test "x$passfull" = "x" ; then 
-       cat<<EOF > /dev/stderr
-When specifying prodcution and/or pass both options -p and -P _must_ 
-be specified. 
-EOF
-       exit 1
-    elif test ! "x$jobid"  = "x" ; then 
-       cat <<EOF > /dev/stderr
-Option -j and options -p ${prodfull} and -P ${passfull} are mutually exclusive 
-EOF
-       exit 1
+    proddir=LHC${prodyear}${prodletter}
+    store=data
+    if test "x$passno" = "x" ; then 
+       err "No pass number"
+    fi 
+    if test "x$passpre" != "x" ; then 
+       passdir=${passpre}
     fi
-fi     
-
-proddir=LHC${prodyear}${prodletter}
-store=${proddir}
-if test ! "x$passno" = "x" ; then 
-    if test "x${passpre}" = "xv" || test "x${passpre}" = "xc"; then 
-       store=${store}/${passpre}pass${passno}
-    else
-       store=${store}/pass${passno}
+    passdir=${passdir}pass${passno}
+    if test "x$passpost" != "x" ; then 
+       passdir=${passdir}_${passpost}
     fi
-elif test ! "x$prodpost" = "x" ; then 
-    proddir=${proddir}${prodpost}
-    store=${proddir}/sim
-elif test ! "x$remainder" = "x" ; then 
-    store=${store}/${remainder}
-fi
+    if test "x$remainder" != "x" ; then 
+       passdir=${passdir}/${remainder}
+    fi
+fi 
+store=${store}/${year}/${proddir}/${passdir}
 if test ! "x$qanumber" = "x" && test $qanumber -gt 0 ; then 
     store=${store}_QA${qanumber}
 fi
 mkdir -p ${top}/$store 
-fix_perm ${top}/${proddir}
 fix_perm ${top}/$store
 
+# --- Check for logging ----------------------------------------------
 if test "x$redir" = "x" ; then 
     redir=${top}/$store/qa.log 
     rm -f $redir
@@ -708,17 +644,21 @@ cat <<EOF
        Use variance:           ${variance}
        Use pre-downloaded:     ${from_local}
 EOF
+
 # --- Do a search to find our files ----------------------------------
 get_filelist
-
+nf=$?
+if test $nf -le 0 ; then 
+    err "No files to process"
+    exit 1
+fi
 if test $maxf -gt 0 && test $maxf -lt $numf ; then 
     numf=$maxf 
 fi
 
 # --- Copy scripts to target and compile -----------------------------
-for i in QABase.h QAPlotter.C QARing.h QAStructs.h QATrender.C \
-    RunFileQA.C RunFinalQA.C ; do
-    cp $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/$i ${store}/${i}
+for i in QABase.h QAPlotter.C QARing.h QAStructs.h QATrender.C ; do
+    cp ${QA_FWD}/$i ${store}/${i}
     rm -f ${store}/`echo $i | tr '.' '_'`.{so,d}
     fix_perm ${store}/${i}
 done
@@ -728,14 +668,14 @@ gROOT->LoadMacro("QABase.h++g");
 gROOT->LoadMacro("QATrender.C++g");
 .q
 EOF
-)
+) 2>> ${redir}
 mess 1 "Compiling QAPlotter.C"
 (cd $store && root -l -b <<EOF 
 gROOT->LoadMacro("QABase.h++g");
 gROOT->LoadMacro("QAPlotter.C++g");
 .q
 EOF
-)
+) 2>> ${redir}
 (cd ${store} && for i in *.so *.d ; do fix_perm $i ; done)
 
 # --- Now get and analyse each run -----------------------------------
@@ -745,19 +685,23 @@ analyse_runs ${top}/$store $numf $files
 make_trend ${top}/$store
 
 # --- Make index files -----------------------------------------------
-make_index ${top}/${proddir} ${proddir}
-# make_index ${top} "QA for the FMD" \
-#    "For more information see <a href='https://twiki.cern.ch/twiki/bin/viewauth/ALICE/FMDQA'>TWiki pages</a>."
-$topmk --title "QA for the FMD" \
-    --description "For more information see <a href='https://twiki.cern.ch/twiki/bin/viewauth/ALICE/FMDQA'>TWiki pages</a>." \
-    --link \
-    --max-depth 2 \
-    --output index.html 
-fix_perm index.html
-copy_aliroot_file $script
-
+if test $index -gt 0 ; then 
+    info -n "Making index ... "
+    desc="For more see <a href='http://cern.ch/go/6Bwz'>TWiki</a>"
+    $topmk --title "QA for the FMD" \
+       --description "$desc" \
+       --link \
+       --max-depth 4 \
+       --frame \
+       --output index.html 
+    # >> ${redir} 2>&1 
+    fix_perm index.html
+    copy_aliroot_file $script
+    ok
+fi 
 chmod -R g+rwX ${top}/${proddir} >> ${redir} 2>&1
 
+
 #
 # EOF
 #