]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Visualization scripts (Jens Wiechula)
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 8 Oct 2009 19:56:47 +0000 (19:56 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 8 Oct 2009 19:56:47 +0000 (19:56 +0000)
TPC/scripts/README [new file with mode: 0644]
TPC/scripts/gui [new file with mode: 0755]
TPC/scripts/guiTime [new file with mode: 0755]
TPC/scripts/makeCalibTree [new file with mode: 0755]
TPC/scripts/makeCalibTreeList [new file with mode: 0755]

diff --git a/TPC/scripts/README b/TPC/scripts/README
new file mode 100644 (file)
index 0000000..b608641
--- /dev/null
@@ -0,0 +1,97 @@
+----------
+Quickstart
+-----------
+Without thinking, you can do the follwoing to create a tree with calibration entries.
+The default settings should work, however you might want to change them for 'better' performance.
+
+Do the following:
+1. Setup environment
+   a. gui dependend variables
+
+export SCRIPTDIR=$ALICE_ROOT/TPC/scripts
+export PATH=$SCRIPTDIR:$PATH
+
+   b. Alien
+
+alien-token-init
+source /tmp/gclient_env_${UID}
+or 
+$ALICE_ROOT/TPC/CalibMacros/alienSetupGSI.sh (GSI specific)
+
+2. Run tree creation
+   a. Run on a list of run numbers with name 'list.txt', one run number per line
+
+makeCalibTree -l list.txt
+
+   b. Run on a range of run numbers:
+
+makeCalibTree -r 75000-80000
+
+
+myrun=70000
+endrun=90000
+bdir=`pwd`
+while [ $myrun -le ${endrun} ]  ; do
+       mydir=$GUI_OUTDIR/tmp/$myrun;
+       mkdirhier $mydir
+       cd $mydir;
+       $BATCHCOMMAND -oo $GUI_OUTDIR/logs/log$myrun.log -eo $GUI_OUTDIR/logs/err$myrun.out  makeCalibTree  -o   -r $myrun-$(($myrun+500));
+       myrun=$(( $myrun +500 )) ;
+       echo $myrun; 
+done;
+cd $bdir
+
+   c. Run automatic tree creation for all runs in the
+      data taking period which was set up (see below)
+      !!!WARNING!!! this will take quite some time
+
+makeCalibTree -a
+
+3. Start the GUI browser
+
+guiTime
+
+
+-------------------
+General information
+-------------------
+The macros and shell scripts used are stored in $ALICE_ROOT/TPC/CalibMacros/guiTime
+If you would like to modify some setting (see below), but do not have write access to this
+directory, you can copy the complete directory somewhere else and setup the environment
+variables accordingly:
+
+export SCRIPTDIR=path_to_my_directory
+export PATH=$SCRIPTDIR:$PATH
+
+- setup scripts
+All user relevant setup is done the shell script 'guiEnv' and the root macro 'ConfigOCDB.C'
+All other files don't need to be modified by the user.
+
+- scripts for the tree creation:
+makeCalibTree:        Steering script to launch the tree creation
+makeCalibTreeList:    script running the actual root process to create the tree
+
+- scripts to start the gui:
+gui 'filename':       Start the CalibViewerGUI using the tree in file 'filename'. Invokes the script
+                      startGUI.C
+guiTime ['filename']: Start the CalibViewerGUItime. Optionally a filename containing the calibration
+                      calibration tree can be specified. Otherwise the trees from the directory setup
+                      in guiEnv will be used (see below). Invokes the script startGUItime.C
+
+-oter scripts:
+loadlibsREC.C:        Root macro to load only libraries needed to start the gui and tree creation.
+
+
+----------------
+Customised setup
+----------------
+
+- Defining the OCDB directories (ConfigOCDB.C):
+Before starting the tree creation or gui the macro 'ConfigOCDB.C' is exectued. This macro should contain
+all the setup needed to point to the proper OCDB directories. If alien is used, alien needs also to be
+setup in the macro. Open the macro for examples.
+
+- General output information (guiEnv):
+In the 'guiEnv' script environment variables defining default output directories etc. See comments in the
+file for explanations.
+
diff --git a/TPC/scripts/gui b/TPC/scripts/gui
new file mode 100755 (executable)
index 0000000..d6277cf
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+if [ $# -ne 1 ]; then
+  echo one file neede das input!
+  exit 1
+fi
+if [ "x$SCRIPTDIR" == "x" ]; then
+  echo
+  echo please run:
+  echo export SCRIPTDIR=whatever_is_your_path
+  echo
+  exit 1
+fi
+source $SCRIPTDIR/guiEnv.sh
+root.exe $SCRIPTDIR/loadlibsREC.C $SCRIPTDIR/startGUI.C\(\"$1\"\)
diff --git a/TPC/scripts/guiTime b/TPC/scripts/guiTime
new file mode 100755 (executable)
index 0000000..73f9958
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+if [ "x$SCRIPTDIR" == "x" ]; then
+  echo 
+  echo please run:
+  echo export SCRIPTDIR=whatever is you path
+  echo
+  exit 1
+fi
+source $SCRIPTDIR/guiEnv.sh
+test -d $GUI_OUTDIR_RUNS || mkdir -p $GUI_OUTDIR_RUNS
+root.exe $SCRIPTDIR/loadlibsREC.C $SCRIPTDIR/ConfigOCDB.C $SCRIPTDIR/startGUItime.C\(\"$1\"\)
diff --git a/TPC/scripts/makeCalibTree b/TPC/scripts/makeCalibTree
new file mode 100755 (executable)
index 0000000..2119c55
--- /dev/null
@@ -0,0 +1,204 @@
+#!/bin/bash
+
+
+function usage {
+echo "Usage:"
+echo "makeCalibTree [options]"
+echo
+echo "options:"
+echo " -r, --range       : create tree for the given range of runs"
+echo "                     e.g. 70000-80000"
+echo " -a, --auto        : create trees in chunks of \$NFILES for all the files"
+echo "                     found in the OCDB entries of \$AUTOFILES"
+echo " -l, --list        : text file with a list of runs to process"
+echo " -d, --outdir      : output file directory"
+echo " -f, --outfile     : output file name"
+echo " -b, --batch       : run as batch job(s)"
+echo " -o, --overwrite   : overwrite old files"
+echo " -h, --help        : display this help"
+echo ""
+exit 0
+
+}
+
+#
+# create a list of files in $RANGE which are also available in $AUTOFILES
+#
+function createRangeList {
+  #get first and last run from range
+  local first=$(echo $RANGE | sed 's|\(.*\)-.*|\1|')
+  local last=$(echo $RANGE | sed 's|.*-\(.*\)|\1|')
+  #create list with all TPC runs
+  local command=ls
+  if [ $WITHALIEN -eq 1 ]; then command=alien_ls; fi
+  local dir=$AUTOFILES
+  RUNS=($($command $dir | sed 's|Run\([0-9]\{5\}\)_.*|\1|'))
+  #define filename
+  local filename=calibTreeTime_${first}_${last}
+  #remove old files
+  #test -d $TMPLISTDIR  && rm -rf $TMPLISTDIR
+  test -d $TMPLISTDIR
+  mkdir -p $TMPLISTDIR
+  for (( i=0; i<${#RUNS[*]}; i=i+1 )); do
+    if [ ${RUNS[$i]} -lt $first ]||[ ${RUNS[$i]} -gt $last ]; then continue; fi
+    echo ${RUNS[$i]} >> $TMPLISTDIR/$filename
+  done
+}
+
+#
+# automatic list creation for runs in files in OCDB entry pointed to by $AUTOFILES
+# crete as many lists as needed in chunks of $NFILES files
+# respect the run range, if given
+#
+function createGuiLists {
+  local command=ls
+  if [ $WITHALIEN -eq 1 ]; then command=alien_ls; fi
+  local dir=$AUTOFILES
+  RUNS=($($command $dir | sed 's|Run\([0-9]\{5\}\)_.*|\1|'))
+  local count=0
+  local iter=0
+  local skip=0
+  local filename=
+  local nfiles=$NFILES
+  #find first and last iterator
+  #get first and last run from range
+  local first=0
+  local last=999999999
+  local ifirst=0
+  local ilast=${#RUNS[*]}
+  if [ "x$RANGE" != "x" ]; then
+    first=$(echo $RANGE | sed 's|\(.*\)-.*|\1|')
+    last=$(echo $RANGE | sed 's|.*-\(.*\)|\1|')
+    for (( i=0; i<${#RUNS[*]}; i=i+1 )); do
+      if [ ${RUNS[i]} -ge $first ]&&[ $ifirst -eq 0 ]; then ifirst=$i; fi
+      if [ ${RUNS[i]} -gt $last ]&&[ $ilast -eq ${#RUNS[*]} ]; then ilast=$i; fi
+    done
+  fi
+  #remove old files
+  #test -d $TMPLISTDIR  && rm -rf $TMPLISTDIR
+  test -d $TMPLISTDIR 
+  mkdir -p $TMPLISTDIR
+  for (( i=$ifirst; i<$ilast; i=i+1 )); do
+    if [ $count -eq $nfiles ]; then
+      count=0
+      let iter=$iter+1
+    fi
+    if [ $count -eq 0 ]; then
+       local firstLocal=$(echo "$iter*$nfiles+$ifirst" | bc)
+       local lastLocal=$(echo "if ($firstLocal+$nfiles-1>=$ilast-$ifirst) $ilast-1 else $firstLocal+$nfiles-1" | bc)
+       filename=calibTreeTime_${RUNS[$firstLocal]}_${RUNS[$lastLocal]}
+    fi
+    echo ${RUNS[$i]} >> $TMPLISTDIR/$filename
+    let count=$count+1
+  done
+}
+
+function runJobs {
+  local count=0;
+  local filename=
+  for file in $TMPLISTDIR/*; do
+    if [ "x$OUTFILE" == "x" ]; then
+      filename=$(basename $file).root
+    else
+      filename=${OUTFILE}_${count}
+    fi
+    if [ $OVERWRITE -eq 0 ];then
+      test -f $OUTDIR/$filename && continue
+    fi
+    if [ $BATCH -eq 0 ]; then
+      $SCRIPTDIR/makeCalibTree -l $file -f $filename -d $OUTDIR
+    else
+      $SCRIPTDIR/makeCalibTree -l $file -f $filename -d $OUTDIR -b
+    fi
+  let count=$count+1
+  done
+}
+
+function runJobOnList {
+    if [ $OVERWRITE -eq 0 ];then
+      if [ -f $OUTDIR/$OUTFILE ]; then
+        echo "Not overwriting file '$OUTDIR/$OUTFILE' use -o to enforce it"
+        exit 0;
+      fi
+    fi
+    if [ $BATCH -eq 1 ]; then
+      $BATCHCOMMAND -oo $GUI_OUTDIR/logs/$OUTFILE.out.log  -eo $GUI_OUTDIR/logs/$OUTFILE.err.log /$SCRIPTDIR/makeCalibTreeList $LISTFILE $OUTDIR/$OUTFILE $SCRIPTDIR
+    else
+      $SCRIPTDIR/makeCalibTreeList $LISTFILE $OUTDIR/$OUTFILE $SCRIPTDIR
+    fi
+}
+
+if [ "x$SCRIPTDIR" == "x" ]; then
+  echo please run:
+  echo export SCRIPTDIR=whatever_is_you_path
+  echo
+  exit 1
+fi
+source $SCRIPTDIR/guiEnv.sh
+        
+      
+#parse options
+TEMP=`getopt -o r:l:f:d:aboh --long range:,list:,calibDir:,outfile:,outdir:,auto,batch,overwrite,help \
+-n 'run' -- "$@"`
+
+if [ $? != 0 ] ; then usage ; fi
+
+eval set -- "$TEMP"
+
+RANGE=
+OUTFILE=
+OVERWRITE=0
+LISTFILE=
+BATCH=0
+COMMAND=
+AUTO=0
+OUTDIR=$GUI_OUTDIR_TIME
+
+while true ; do
+  case "$1" in
+  -r|--range)     RANGE=$2;    shift 2;;
+  -l|--list)      LISTFILE=$2; shift 2;;
+  -f|--outfile)   OUTFILE=$2;  shift 2;;
+  -d|--outdir)    OUTDIR=$2;   shift 2;;
+  -a|--auto)      AUTO=1;      shift;;
+  -b|--batch)     BATCH=1;     shift;;
+  -o|--overwrite) OVERWRITE=1; shift;;
+  -h|--help)      usage;;
+  --) shift ; break ;;
+  *) echo "Internal error!" ; exit 1 ;;
+  esac
+done
+
+
+
+if [ $AUTO -eq 1 ]; then
+  test -d $OUTDIR || mkdir -p $OUTDIR
+  #remove last file if it does not contain $NFILES files
+  lastfile=$(ls $OUTDIR/* | tail -1)
+  if [ "x$lastfile" != "x" ]; then
+    nfiles=$(wc -l $lastfile | awk '{print $1}')
+    if [ $nfiles -ne $NFILES ]; then
+      rm $lastfile
+    fi
+  fi
+  createGuiLists
+  runJobs
+  echo "files written to '$OUTDIR'"
+  exit 0
+fi
+
+if [ "x$RANGE" != "x" ]&&[ "x$LISTFILE" == "x" ]; then
+  test -d $OUTDIR || mkdir -p $OUTDIR
+  createRangeList
+  runJobs
+  exit 0
+fi
+
+if [ "x$RANGE" == "x" ]&&[ "x$LISTFILE" != "x" ]; then
+  test -d $OUTDIR || mkdir -p $OUTDIR
+  runJobOnList
+  exit 0
+fi
+
+#we should have left already, so show usage
+usage
\ No newline at end of file
diff --git a/TPC/scripts/makeCalibTreeList b/TPC/scripts/makeCalibTreeList
new file mode 100755 (executable)
index 0000000..e2e6be8
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+#parameters
+#1: listfile
+#2: outfile
+#3: bindir
+
+. $3/guiEnv.sh
+
+#temporary working directory
+dirID=/tmp/$(whoami)/$(date +%F.%H.%M.%S.%N)_$(basename $1)
+
+test -d $dirID || mkdir -p $dirID
+cd $dirID
+root.exe -q -b $3/loadlibsREC.C $3/ConfigOCDB.C $ALICE_ROOT/TPC/CalibMacros/CalibEnv.C+\(\"$1\"\)
+mv dcsTime.root $2
+rmdir $dirID