]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - share/alirun
macro and flowevent maker to run part of the code in root
[u/mrichter/AliRoot.git] / share / alirun
index fd5dbdd626f9cc52a52137eaf7aea39a3d641d8e..ae4e3f2d46c4f2e705cf8787d072738850695679 100755 (executable)
@@ -4,7 +4,18 @@
 #############################################################################
 #
 # modification history
+#
 # $Log$
+# Revision 1.7  2001/05/21 17:22:52  buncic
+# Fixed problem with missing AliConfig while reading galice.root
+#
+# Revision 1.6  2001/05/16 14:57:30  alibrary
+# New files for folders and Stack
+#
+#
+# Revision 1.5  2001/02/23 17:33:40  buncic
+# Added alifs wrapper for CASTOR and alirun modified accordingly.
+#
 # Revision 1.4  2001/02/08 18:55:43  buncic
 # Support for writing to remote file systems (shift/castor).
 #
@@ -45,7 +56,7 @@
 #     - Reco ................ reconstruction
 #
 # -d <TPC+ITS+..> | -d all | -all 
-#    Selects detector for which <command> will be run. If none of these options was specified, an internal loop in AliRoot over all active detectors is assumed.  Otherwise, for each detector, input file(s) are re-opened in update mode, command (or macro) is executed and the file is closed. Option -all is equivalent to MUON+RICH+TOF+ITS+TPC+PHOS+PMD+CASTOR+TRD. Detectors are processed in order as they appear on the command line.   
+#    Selects detector for which <command> will be run. If none of these options was specified, an internal loop in AliRoot over all active detectors is assumed.  Otherwise, for each detector, input file(s) are re-opened in update mode, command (or macro) is executed and the file is closed. Option -all is equivalent to MUON+HMPID+TOF+ITS+TPC+PHOS+PMD+CASTOR+TRD. Detectors are processed in order as they appear on the command line.   
 #
 # -f <file>
 #    Name of the top level Root file where Root trees will be stored (branches may reside in the same file or be diverted to separate files (see -split option). By default, file is named galice.root.
 # -debugger <command_name>
 #    Execute AliRoot under debugger other than gdb. 
 #
+# -debuglevel <level>
+#    Set AliRoot debug flag to <level>.
+#
 # -break <breakpoint>
 #    Execute AliRoot under gdb and set <breakpoint>.
 #
 #    
 #    alirun -o /tmp/event.2 -f test.root -split -p 100 -c Hits
 #
-#   Use output from first step and create TOF and RICH digits. Output is in the same direcory and in file test.root
+#   Use output from first step and create TOF and HMPID digits. Output is in the same direcory and in file test.root
 #
-#    alirun -d TOF+RICH -o /tmp/event.1 -c Digits
+#    alirun -d TOF+HMPID -o /tmp/event.1 -c Digits
 #
 #   Use output from second step and create digits for all detectors. Output is in the same direcory and branches are diverted to separate files:
 #
@@ -155,6 +169,7 @@ then
   exec $ALIRUN_SHELL -norc  -noprofile $0 $*
 fi
 
+
 ###########################################################################
 AliRun()
 ###########################################################################
@@ -171,6 +186,38 @@ AliRun()
    exit
 }
 
+###########################################################################
+AliSetRoot()
+###########################################################################
+{
+  ALICE_ROOT=$1;                       export ALICE_ROOT
+  ALICE=`dirname $ALICE_ROOT`;         export ALICE          
+  ALICE_LEVEL=`basename $ALICE_ROOT`;  export ALICE_LEVEL
+  ALICE_TARGET=`uname`;                export ALICE_TARGET
+  ROOTSYS=$2;                          export ROOTSYS
+  
+  LD_LIBRARY_PATH=$ROOTSYS/lib
+
+  if [ -f $ALICE/bin/changeRoot.sh ]
+  then
+    .   $ALICE/bin/changeRoot.sh \
+              $ALICE $ALICE_LEVEL $ALICE_TARGET $ROOTSYS
+  fi
+
+  if [ ! -x $ALICE_BIN/aliroot -o ! -x $ROOTSYS/bin/root ]
+  then
+     printf "Invalid Alice library directory: %s\n" $1
+     exit 1 
+  fi
+
+  LD_LIBRARY_PATH=${ROOTSYS}/lib:${ALICE_LIB}; export LD_LIBRARY_PATH
+  PATH=${ALICE_BIN}:${ROOTSYS}/bin:${PATH}; export PATH
+
+  printf "ALICE environment reset to %s\n" $ALICE_ROOT
+  which root
+  which aliroot
+}
+
 ###########################################################################
 Mktemp()
 ###########################################################################
@@ -330,7 +377,9 @@ void Simulate()
    
    gAlice->Init(gSystem->Getenv("CONFIG"));
 
-   gAlice->Run(1);
+   $DEBUG_LEVEL;
+
+   gAlice->RunMC($NEVENTS);
 }
 ////////////////////////////////////////////////////////////////////////////
 
@@ -364,6 +413,8 @@ void $mode()
    
    AliRun *gAlice = (AliRun*)file->Get("gAlice");
   
+   $DEBUG_LEVEL;
+
    gAlice->$mode(gSystem->Getenv("CONFIG_DETECTOR"));
 }
 ////////////////////////////////////////////////////////////////////////////
@@ -401,12 +452,12 @@ AliRunHits()
 }
 
 ###########################################################################
-AliRunDigits()
+AliRunSplitCmd()
 ###########################################################################
 {
   if [ "$DETECTORS" = "" ]
   then
-    AliRoot Digits 
+    AliRoot $1
   else
     for det in $DETECTORS
     do
@@ -415,21 +466,35 @@ AliRunDigits()
       then
         if [ "$LSF_FORK" = "TRUE" ]
         then
-          lsrun AliRoot Digits $CONFIG_DETECTOR
+          lsrun AliRoot $1 $CONFIG_DETECTOR
         else
-          AliRoot Digits $CONFIG_DETECTOR &
+          AliRoot $1 $CONFIG_DETECTOR &
         fi
       else
-        AliRoot Digits $CONFIG_DETECTOR
+        AliRoot $1 $CONFIG_DETECTOR
       fi
     done
     wait
   fi
 }
 
+###########################################################################
+AliRunDigits()
+###########################################################################
+{
+  AliRunSplitCmd Digits
+}
+
+###########################################################################
+AliRunReco()
+###########################################################################
+{
+  AliRunSplitCmd Reco
+}
+
 ###########################################################################
 
-ALL="MUON RICH TOF ITS TPC PHOS PMD CASTOR ZDC TRD"; 
+ALL="MUON HMPID TOF ITS TPC PHOS PMD CASTOR ZDC TRD"; 
 DETECTORS="";                                        
 FILE="galice.root";  
 
@@ -442,13 +507,16 @@ ALIRUN_TMPDIR=`Mktemp`; export ALIRUN_TMPDIR
 ALIRUN_DEBUGGER=gdb
 
 DEBUG="FALSE"
+DEBUG_LEVEL=""
 BREAK=""
 VERBOSE="TRUE"
 OUTPUT=.
-CMDLIST="Usage"
+CMDLIST=""
 FORK="FALSE"
 FORK_LSF="FALSE"
+BATCH="FALSE"
 ECHO=""
+NEVENTS=1
 USE_CACHE="file->UseCache()"
 
 if [ -x /usr/local/lsf/bin/lsrun ] 
@@ -476,6 +544,10 @@ do
             shift 1
             ALIRUN_DEBUGGER=$1
             ;;
+        -debuglevel)
+            shift 1
+            DEBUG_LEVEL="gAlice->SetDebug($1)"
+            ;;
         -break)
             shift 1
             DEBUG="TRUE"
@@ -485,6 +557,15 @@ do
             shift 1
             set -vx
             ;;
+        -setroot)
+            shift 1
+            AliSetRoot $1 $2
+            shift 1
+            ;;
+        -batch)
+            shift 1
+            BATCH="TRUE"
+            ;;
         -echo)
             shift 1
             ECHO="echo "
@@ -569,6 +650,11 @@ do
     esac
 done
 
+if [ "$CMDLIST" = "" ]
+then
+  AliRun
+fi
+
 if [ `dirname $OUTPUT` = "." ]
 then
   CONFIG_OUTDIR=`pwd`/$OUTPUT
@@ -624,10 +710,10 @@ then
   $MKDIR -p $CONFIG_OUTDIR
 fi
 
-mkdir -p $ALIRUN_TMPDIR
-
 CONFIG_FILE=$CONFIG_FILE_PREFIX$CONFIG_OUTDIR/$FILE; export CONFIG_FILE
 
+mkdir -p $ALIRUN_TMPDIR
+
 trap Cleanup 2
 
 (