X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=share%2Falirun;h=ae4e3f2d46c4f2e705cf8787d072738850695679;hb=b3536bfc59b1abae84a6aae7c815063d1ee1d0fc;hp=dd6066ffe24eba8c020ee8bc4f899bdfda31d240;hpb=e0381e2291faf1320eaa3ccc02d1f14812c5520a;p=u%2Fmrichter%2FAliRoot.git diff --git a/share/alirun b/share/alirun index dd6066ffe24..ae4e3f2d46c 100755 --- a/share/alirun +++ b/share/alirun @@ -4,7 +4,30 @@ ############################################################################# # # 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). +# +# Revision 1.3 2001/02/01 18:00:23 buncic +# Use bash in place of sh for compatibility +# +# Revision 1.2 2001/02/01 17:46:26 buncic +# Fixed mktemp on HP and Sun +# +# Revision 1.1 2001/01/26 21:22:02 hristov +# Major upgrade of AliRoot code +# # # SYNOPSIS # alirun [[-d |-all]] @@ -30,15 +53,20 @@ # - Digits .............. digitisation # - SDigits ............. creation of sumable digits # - SDigits2Digits ...... conversion SDigits->Digits +# - Reco ................ reconstruction # # -d | -d all | -all -# Selects detector for which 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 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 # 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. # # -o -# A directory where output file(s) will be stored. If does not exist, it will be created. If not specified, current directory is used. +# A directory where output file(s) will be stored. If does not exist, it will be created. If not specified, current directory is used. One can prefix the directory name with a string indicting file transport protocols (as supported by ROOT). In addition, some file transport protocols are selected by name signatures. At present the following methods are available: +# +# o) if file name begins with rfio:, shift:, castor:, hpss:, /shift, /castor, /hpss => rfio (remote file i/o) protocol (requires rfiod on server side) +# o) if file name begins with root:, roots: => root and secure root protocol (requires rootd on server side) +# o) if file name begins with http: => HTTP protocol (requires modified apache server on server side) # # -split # If specified, this option will tell AliRoot to divert branches of Root trees into separate files. @@ -86,6 +114,12 @@ # -debug # Execute AliRoot under gdb. # +# -debugger +# Execute AliRoot under debugger other than gdb. +# +# -debuglevel +# Set AliRoot debug flag to . +# # -break # Execute AliRoot under gdb and set . # @@ -93,21 +127,21 @@ # Create man page for alirun. # # EXAMPLES -# Run sumulation for 1 event, 100 particles and store output in file test.root in /tmp/event.1 directory: +# Run sumulation for 1 event, 100 particles and store output in file galice.root in /tmp/event.1 directory: # -# alirun -o /tmp/event.1 -f test.root -p 100 -verbose -c Hits +# alirun -o /tmp/event.1 -p 100 -c Hits # -# Run sumulation for 1 event, 100 particles and store output in default file galice.root in /tmp/event.1 directory. In adition, divert branches of TreeD,TreeR and TreeK into separate files: +# Run sumulation for 1 event, 100 particles and store output in file test.root in /tmp/event.2 directory. In adition, divert branches of TreeD,TreeR and TreeK into separate files: # -# alirun -o /tmp/event.2 -split -p 100 -verbose -c Hits +# 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 -f test.root -verbose -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: # -# alirun -d all -o /tmp/event.2 -split -verbose -c Digits +# alirun -d all -o /tmp/event.2 -f test.root -split -c Digits # # AUTHOR: # Predrag Buncic, e-mail: Predrag.Buncic@cern.ch @@ -118,6 +152,24 @@ #C< ########################################################################### +if [ "$ALIRUN_SHELL" = "" ] +then + ALIRUN_SHELL=bin/sh + for shell in bash zsh ksh + do + for dir in /bin /usr/bin /usr/local/bin + do + if [ -x $dir/$shell ] + then + ALIRUN_SHELL=$dir/$shell; export ALIRUN_SHELL + break 2 + fi + done + done + exec $ALIRUN_SHELL -norc -noprofile $0 $* +fi + + ########################################################################### AliRun() ########################################################################### @@ -134,20 +186,93 @@ 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() ########################################################################### { - mktemp -qu /tmp/alirun.$$.XXXXXX +# mktemp -qu /tmp/alirun.$$.XXXXXX + echo /tmp/alirun.$$. +} + +########################################################################### +ConfigureIO() +########################################################################### +{ + if [ "$1" != "" ] + then + case $1 in + CASTOR) + MKDIR="alifs mkdir" + RMDIR="alifs rm -r" + STAT="/usr/local/bin/rfstat" + if [ "$STAGE_HOST" = "" ] + then + unset STAGE_HOST + fi + if [ "$STAGE_POOL" = "" ] + then + unset STAGE_POOL + fi + ;; + RFIO) + MKDIR="/usr/local/bin/rfmkdir" + RMDIR="echo y | /usr/local/bin/rfrm -r" + STAT="/usr/local/bin/rfstat" + ;; + LOCAL) + MKDIR="mkdir" + RMDIR="rm -rf" + STAT="test -d" + ;; + *) + printf "%s I/O not yet supported by alirun.\n" $1 + exit 255 + ;; + esac + fi } + ########################################################################### Cleanup() ########################################################################### { - if [ -d $ALIRUN_TMPDIR ] + $STAT $ALIRUN_TMPDIR > /dev/null 2>&1 + if [ $? -eq 0 ] then - rm -rf $ALIRUN_TMPDIR + $RMDIR $ALIRUN_TMPDIR >/dev/null 2>&1 fi } @@ -160,13 +285,16 @@ AliRoot() macro=`HitsMacro` ;; Digits) - macro=`DigitsMacro Hits2Digits` + macro=`GenericMacro Hits2Digits` ;; SDigits) - macro=`DigitsMacro Hits2SDigits` + macro=`GenericMacro Hits2SDigits` ;; SDigits2Digits) - macro=`DigitsMacro SDigits2Digits` + macro=`GenericMacro SDigits2Digits` + ;; + Reco) + macro=`GenericMacro RunReco` ;; *.C|*.C\(*\)) macro=$1 @@ -203,11 +331,15 @@ b $BREAK c where EOF - $ECHO gdb -q -x $ALIRUN_TMPDIR/gdb aliroot + $ECHO $ALIRUN_DEBUGGER -q -x $ALIRUN_TMPDIR/gdb aliroot else if [ "$VERBOSE" = "TRUE" ] then $ECHO aliroot -q -b $macro + if [ $? -ne 0 ] + then + exit $? + fi else $ECHO aliroot -q -b $macro > $stdout 2>&1 if [ $? -ne 0 ] @@ -235,9 +367,19 @@ HitsMacro() //////////////////////////////////////////////////////////////////////////// void Simulate() { + TFile *file = TFile::Open(gSystem->Getenv("CONFIG_FILE"),"recreate"); + + $USE_CACHE; + + file->SetCompressionLevel(2); + + gAlice->SetBaseFile(gSystem->DirName(gSystem->Getenv("CONFIG_FILE"))); + gAlice->Init(gSystem->Getenv("CONFIG")); - gAlice->Run(1); + $DEBUG_LEVEL; + + gAlice->RunMC($NEVENTS); } //////////////////////////////////////////////////////////////////////////// @@ -246,24 +388,33 @@ EOF } ########################################################################### -DigitsMacro() +GenericMacro() ########################################################################### { mode=$1 - macro=$ALIRUN_TMPDIR/Digitize.C + macro=$ALIRUN_TMPDIR/$mode.C cat < $macro //////////////////////////////////////////////////////////////////////////// -void Digitize() +void $mode() { - gAlice->OpenBaseFile("update"); + TFile *file = TFile::Open(gSystem->Getenv("CONFIG_FILE"),"update"); + if (! file ) { + cout << "Could not open Hits file. Exiting..." << endl; + exit(1); + } + file->SetCompressionLevel(2); + + $USE_CACHE; if (gAlice) delete gAlice; - AliRun *gAlice = (AliRun*)gDirectory->Get("gAlice"); + AliRun *gAlice = (AliRun*)file->Get("gAlice"); + $DEBUG_LEVEL; + gAlice->$mode(gSystem->Getenv("CONFIG_DETECTOR")); } //////////////////////////////////////////////////////////////////////////// @@ -276,15 +427,14 @@ EOF AliRunMakeman() ########################################################################### { - mangen -n tool $0 + mandir=../man/man4 + ./mangen -n tool $0 if [ $? -eq 0 ] then - if [ -d ../man/man4 ] - then - mv $0.? ../man/man4 - fi + [ ! -d $mandir ] && mkdir -p $mandir + mv `basename $0`.? $mandir + exit fi - exit } ########################################################################### @@ -302,53 +452,72 @@ AliRunHits() } ########################################################################### -AliRunDigits() +AliRunSplitCmd() ########################################################################### { if [ "$DETECTORS" = "" ] then - AliRoot Digits + AliRoot $1 else for det in $DETECTORS do - export CONFIG_DETECTOR=$det; + CONFIG_DETECTOR=$det; export CONFIG_DETECTOR if [ "$FORK" = "TRUE" ] 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 +} ########################################################################### -export ALL="MUON RICH TOF ITS TPC PHOS PMD CASTOR ZDC TRD" -export DETECTORS="" -export CONFIG_FILE="galice.root" -export CONFIG=$ALICE_ROOT/macros/Config.C -export CONFIG_NPARTICLES=50 -export CONFIG_PATH=`pwd` +ALL="MUON HMPID TOF ITS TPC PHOS PMD CASTOR ZDC TRD"; +DETECTORS=""; +FILE="galice.root"; + +CONFIG=$ALICE_ROOT/macros/Config.C; export CONFIG +CONFIG_NPARTICLES=50; export CONFIG_NPARTICLES +CONFIG_PATH=`pwd`; export CONFIG_PATH +CONFIG_BATCH="TRUE"; export CONFIG_BATCH -export ALIRUN_TMPDIR=`Mktemp` +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 ] then @@ -359,7 +528,7 @@ for config in $CONFIG_PATH/Config.C $ALICE_ROOT/macros/Config.C do if [ -f $config ] then - export CONFIG=$config + CONFIG=$config; export CONFIG break fi done @@ -371,6 +540,14 @@ do shift 1 DEBUG="TRUE" ;; + -debugger) + shift 1 + ALIRUN_DEBUGGER=$1 + ;; + -debuglevel) + shift 1 + DEBUG_LEVEL="gAlice->SetDebug($1)" + ;; -break) shift 1 DEBUG="TRUE" @@ -380,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 " @@ -422,11 +608,11 @@ do ;; -split) shift 1 - export CONFIG_SPLIT_FILE="TRUE" + CONFIG_SPLIT_FILE="TRUE"; export CONFIG_SPLIT_FILE ;; -f) shift 1 - export CONFIG_FILE=$1 + FILE=$1 ;; -n) shift 1 @@ -434,11 +620,15 @@ do ;; -p) shift 1 - export CONFIG_NPARTICLES=$1 + CONFIG_NPARTICLES=$1; export CONFIG_NPARTICLES ;; -seed) shift 1 - export CONFIG_SEED=$1 + CONFIG_SEED=$1; export CONFIG_SEED + ;; + -nocache) + shift 1 + USE_CACHE="" ;; -c) shift 1 @@ -447,7 +637,12 @@ do ;; -C) shift 1 - export CONFIG=$1 + CONFIG=$1; + if [ `dirname $CONFIG` = "." ] + then + CONFIG=`pwd`/$CONFIG + fi + export CONFIG ;; *) shift 1 @@ -455,19 +650,74 @@ do esac done +if [ "$CMDLIST" = "" ] +then + AliRun +fi if [ `dirname $OUTPUT` = "." ] then - OUTPUT=`pwd`/$OUTPUT + CONFIG_OUTDIR=`pwd`/$OUTPUT +else + CONFIG_OUTDIR=$OUTPUT fi -[ ! -d $OUTPUT ] && mkdir -p $OUTPUT -[ ! -d $ALIRUN_TMPDIR ] && mkdir -p $ALIRUN_TMPDIR +case $CONFIG_OUTDIR in + rfio:*|/shift/*|shift:*) + CONFIG_FILE_PREFIX="rfio:" + ConfigureIO RFIO + ;; + /castor/*|castor:*|hpss:*) + CONFIG_FILE_PREFIX="rfio:" + ConfigureIO CASTOR + ;; + hpss:*) + CONFIG_FILE_PREFIX="rfio:" + ConfigureIO RFIO + ;; + root:*) + CONFIG_FILE_PREFIX="root:" + ConfigureIO ROOT + ;; + roots:*) + CONFIG_FILE_PREFIX="roots:" + ConfigureIO ROOT + ;; + http:*) + CONFIG_FILE_PREFIX="http:" + ConfigureIO HTTP + ;; + file:*) + CONFIG_FILE_PREFIX="" + ConfigureIO LOCAL + ;; + /*) + CONFIG_FILE_PREFIX="" + ConfigureIO LOCAL + ;; + *) + CONFIG_FILE_PREFIX=`pwd`/ + ConfigureIO LOCAL + ;; +esac + +export CONFIG_OUTDIR +export CONFIG_FILE_PREFIX + +$STAT $CONFIG_OUTDIR > /dev/null 2>&1 +if [ $? -ne 0 ] +then + $MKDIR -p $CONFIG_OUTDIR +fi + +CONFIG_FILE=$CONFIG_FILE_PREFIX$CONFIG_OUTDIR/$FILE; export CONFIG_FILE + +mkdir -p $ALIRUN_TMPDIR trap Cleanup 2 ( - cd $OUTPUT + cd $ALIRUN_TMPDIR for cmd in $CMDLIST do case `type -t AliRun$cmd` in @@ -481,4 +731,4 @@ trap Cleanup 2 done ) -Cleanup \ No newline at end of file +Cleanup