2 #############################################################################
3 # alirun - a shell script to run AliRoot
4 #############################################################################
8 # Revision 1.1 2001/01/26 21:22:02 hristov
9 # Major upgrade of AliRoot code
13 # alirun [[-d <TPC+ITS+..>|-all]]
15 # [-o <output directory>]
19 # [-seed <seed for random number generator>]
24 # This script is a wrapper for AliRoot and provides a command line interface suitable for running in batch mode.
26 # CONFIGURATION OPTIONS
27 # The following options are used to configure AliRoot session.
29 # -c <command1 command2 ...>
30 # This option must be the last one on alirun command line and specifies the sequence of alirun commands to be executed. At present, the following commands are supported:
32 # - Hits ................ simulation
33 # - Digits .............. digitisation
34 # - SDigits ............. creation of sumable digits
35 # - SDigits2Digits ...... conversion SDigits->Digits
37 # -d <TPC+ITS+..> | -d all | -all
38 # 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.
41 # 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.
44 # A directory where output file(s) will be stored. If does not exist, it will be created. If not specified, current directory is used.
47 # If specified, this option will tell AliRoot to divert branches of Root trees into separate files.
49 # The layout of output directory is the following:
52 # |-- Digits.<detector>.root
53 # |-- SDigits.<detector>.root
60 # An alternative to Config.C macro which contains AliRoot configuration.
63 # Number of primary particles to be generated by selected event generator. Required for Hits command, Ignored by Digits command (digitisation is performed for all particles found in input file). Default value is 50.
66 # Seed for random number generator (used to initialise TRandom3(n)).
69 # Number of events to generate (not yet implemented).
72 # These options define run time appearance of the AliRoot session.
78 # Switch verbose screen output on.
81 # Switch verbose output off. Output is redirected to a file which is shown on standard output only if <command> returns non zero status.
84 # Forks all digitisation processes in background, using LSF if available, in order to speed up execution. It cannot be used in present design where only tree branches are diverted to separate files as top level Root file must be kept open in update mode.
87 # Show trace of execution of shell commands.
90 # Execute AliRoot under gdb.
93 # Execute AliRoot under gdb and set <breakpoint>.
96 # Create man page for alirun.
99 # Run sumulation for 1 event, 100 particles and store output in file test.root in /tmp/event.1 directory:
101 # alirun -o /tmp/event.1 -f test.root -p 100 -verbose -c Hits
103 # 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:
105 # alirun -o /tmp/event.2 -split -p 100 -verbose -c Hits
107 # Use output from first step and create TOF and RICH digits. Output is in the same direcory and in file test.root
109 # alirun -d TOF+RICH -o /tmp/event.1 -f test.root -verbose -c Digits
111 # Use output from second step and create digits for all detectors. Output is in the same direcory and branches are diverted to separate files:
113 # alirun -d all -o /tmp/event.2 -split -verbose -c Digits
116 # Predrag Buncic, e-mail: Predrag.Buncic@cern.ch
122 ###########################################################################
124 ###########################################################################
126 ###########################################################################
128 printf "Usage: alirun [[-d <TPC+ITS+..>|-all]]\n"
129 printf " [-f <hits file>]\n"
130 printf " [-o <output directory>]\n"
132 printf " [-C <Config.C>]\n"
133 printf " [-p <particle#>]\n"
134 printf " [-seed <seed for random number generator>]\n"
135 printf " [-n event #]\n"
136 printf " <-c <command ...>>\n"
140 ###########################################################################
142 ###########################################################################
144 # mktemp -qu /tmp/alirun.$$.XXXXXX
148 ###########################################################################
150 ###########################################################################
152 if [ -d $ALIRUN_TMPDIR ]
154 rm -rf $ALIRUN_TMPDIR
158 ###########################################################################
160 ###########################################################################
167 macro=`DigitsMacro Hits2Digits`
170 macro=`DigitsMacro Hits2SDigits`
173 macro=`DigitsMacro SDigits2Digits`
179 printf "Unknown command: %s. Terminating...\n" $1
191 stdout=$ALIRUN_TMPDIR/STDOUT.$${$CONTEXT}
193 hr="========================================"
195 if [ "$VERBOSE" = "FALSE" ]
197 printf "%s\n+ aliroot -q -b %s %s\n%s\n" $hr$hr $1 $CONTEXT $hr$hr
200 if [ "$DEBUG" = "TRUE" ]
202 cat<<EOF>$ALIRUN_TMPDIR/gdb
210 $ECHO gdb -q -x $ALIRUN_TMPDIR/gdb aliroot
212 if [ "$VERBOSE" = "TRUE" ]
214 $ECHO aliroot -q -b $macro
216 $ECHO aliroot -q -b $macro > $stdout 2>&1
219 echo "- "aliroot -q -b " "$1" "$CONTEXT
223 echo "+ "aliroot -q -b " "$1" "$CONTEXT
231 ###########################################################################
233 ###########################################################################
235 macro=$ALIRUN_TMPDIR/Simulate.C
239 ////////////////////////////////////////////////////////////////////////////
242 gAlice->Init(gSystem->Getenv("CONFIG"));
246 ////////////////////////////////////////////////////////////////////////////
252 ###########################################################################
254 ###########################################################################
258 macro=$ALIRUN_TMPDIR/Digitize.C
262 ////////////////////////////////////////////////////////////////////////////
265 gAlice->OpenBaseFile("update");
267 if (gAlice) delete gAlice;
269 AliRun *gAlice = (AliRun*)gDirectory->Get("gAlice");
271 gAlice->$mode(gSystem->Getenv("CONFIG_DETECTOR"));
273 ////////////////////////////////////////////////////////////////////////////
279 ###########################################################################
281 ###########################################################################
286 if [ -d ../man/man4 ]
294 ###########################################################################
296 ###########################################################################
301 ###########################################################################
303 ###########################################################################
308 ###########################################################################
310 ###########################################################################
312 if [ "$DETECTORS" = "" ]
316 for det in $DETECTORS
318 CONFIG_DETECTOR=$det; export CONFIG_DETECTOR
319 if [ "$FORK" = "TRUE" ]
321 if [ "$LSF_FORK" = "TRUE" ]
323 lsrun AliRoot Digits $CONFIG_DETECTOR
325 AliRoot Digits $CONFIG_DETECTOR &
328 AliRoot Digits $CONFIG_DETECTOR
337 ###########################################################################
339 ALL="MUON RICH TOF ITS TPC PHOS PMD CASTOR ZDC TRD"; export ALL
340 DETECTORS=""; export DETECTORS
341 CONFIG_FILE="galice.root"; export CONFIG_FILE
342 CONFIG=$ALICE_ROOT/macros/Config.C; export CONFIG
343 CONFIG_NPARTICLES=50; export CONFIG_NPARTICLES
344 CONFIG_PATH=`pwd`; export CONFIG_PATH
346 ALIRUN_TMPDIR=`Mktemp`; export ALIRUN_TMPDIR
357 if [ -x /usr/local/lsf/bin/lsrun ]
362 for config in $CONFIG_PATH/Config.C $ALICE_ROOT/macros/Config.C
366 CONFIG=$config; export CONFIG
412 if [ "$list" = "all" ]
416 DETECTORS=`echo $list | sed 's/+/ /g'`
429 CONFIG_SPLIT_FILE="TRUE"; export CONFIG_SPLIT_FILE
433 CONFIG_FILE=$1; export CONFIG_FILE
441 CONFIG_NPARTICLES=$1; export CONFIG_NPARTICLES
445 CONFIG_SEED=$1; export CONFIG_SEED
454 CONFIG=$1; export CONFIG
463 if [ `dirname $OUTPUT` = "." ]
468 [ ! -d $OUTPUT ] && mkdir -p $OUTPUT
469 [ ! -d $ALIRUN_TMPDIR ] && mkdir -p $ALIRUN_TMPDIR
477 case `type -t AliRun$cmd` in