2 #############################################################################
3 # alirun - a shell script to run AliRoot
4 #############################################################################
8 # Revision 1.2 2001/02/01 17:46:26 buncic
9 # Fixed mktemp on HP and Sun
11 # Revision 1.1 2001/01/26 21:22:02 hristov
12 # Major upgrade of AliRoot code
16 # alirun [[-d <TPC+ITS+..>|-all]]
18 # [-o <output directory>]
22 # [-seed <seed for random number generator>]
27 # This script is a wrapper for AliRoot and provides a command line interface suitable for running in batch mode.
29 # CONFIGURATION OPTIONS
30 # The following options are used to configure AliRoot session.
32 # -c <command1 command2 ...>
33 # 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:
35 # - Hits ................ simulation
36 # - Digits .............. digitisation
37 # - SDigits ............. creation of sumable digits
38 # - SDigits2Digits ...... conversion SDigits->Digits
40 # -d <TPC+ITS+..> | -d all | -all
41 # 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.
44 # 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.
47 # A directory where output file(s) will be stored. If does not exist, it will be created. If not specified, current directory is used.
50 # If specified, this option will tell AliRoot to divert branches of Root trees into separate files.
52 # The layout of output directory is the following:
55 # |-- Digits.<detector>.root
56 # |-- SDigits.<detector>.root
63 # An alternative to Config.C macro which contains AliRoot configuration.
66 # 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.
69 # Seed for random number generator (used to initialise TRandom3(n)).
72 # Number of events to generate (not yet implemented).
75 # These options define run time appearance of the AliRoot session.
81 # Switch verbose screen output on.
84 # Switch verbose output off. Output is redirected to a file which is shown on standard output only if <command> returns non zero status.
87 # 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.
90 # Show trace of execution of shell commands.
93 # Execute AliRoot under gdb.
96 # Execute AliRoot under gdb and set <breakpoint>.
99 # Create man page for alirun.
102 # Run sumulation for 1 event, 100 particles and store output in file test.root in /tmp/event.1 directory:
104 # alirun -o /tmp/event.1 -f test.root -p 100 -verbose -c Hits
106 # 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:
108 # alirun -o /tmp/event.2 -split -p 100 -verbose -c Hits
110 # Use output from first step and create TOF and RICH digits. Output is in the same direcory and in file test.root
112 # alirun -d TOF+RICH -o /tmp/event.1 -f test.root -verbose -c Digits
114 # Use output from second step and create digits for all detectors. Output is in the same direcory and branches are diverted to separate files:
116 # alirun -d all -o /tmp/event.2 -split -verbose -c Digits
119 # Predrag Buncic, e-mail: Predrag.Buncic@cern.ch
125 ###########################################################################
127 ###########################################################################
129 ###########################################################################
131 printf "Usage: alirun [[-d <TPC+ITS+..>|-all]]\n"
132 printf " [-f <hits file>]\n"
133 printf " [-o <output directory>]\n"
135 printf " [-C <Config.C>]\n"
136 printf " [-p <particle#>]\n"
137 printf " [-seed <seed for random number generator>]\n"
138 printf " [-n event #]\n"
139 printf " <-c <command ...>>\n"
143 ###########################################################################
145 ###########################################################################
147 # mktemp -qu /tmp/alirun.$$.XXXXXX
151 ###########################################################################
153 ###########################################################################
155 if [ -d $ALIRUN_TMPDIR ]
157 rm -rf $ALIRUN_TMPDIR
161 ###########################################################################
163 ###########################################################################
170 macro=`DigitsMacro Hits2Digits`
173 macro=`DigitsMacro Hits2SDigits`
176 macro=`DigitsMacro SDigits2Digits`
182 printf "Unknown command: %s. Terminating...\n" $1
194 stdout=$ALIRUN_TMPDIR/STDOUT.$${$CONTEXT}
196 hr="========================================"
198 if [ "$VERBOSE" = "FALSE" ]
200 printf "%s\n+ aliroot -q -b %s %s\n%s\n" $hr$hr $1 $CONTEXT $hr$hr
203 if [ "$DEBUG" = "TRUE" ]
205 cat<<EOF>$ALIRUN_TMPDIR/gdb
213 $ECHO gdb -q -x $ALIRUN_TMPDIR/gdb aliroot
215 if [ "$VERBOSE" = "TRUE" ]
217 $ECHO aliroot -q -b $macro
219 $ECHO aliroot -q -b $macro > $stdout 2>&1
222 echo "- "aliroot -q -b " "$1" "$CONTEXT
226 echo "+ "aliroot -q -b " "$1" "$CONTEXT
234 ###########################################################################
236 ###########################################################################
238 macro=$ALIRUN_TMPDIR/Simulate.C
242 ////////////////////////////////////////////////////////////////////////////
245 gAlice->Init(gSystem->Getenv("CONFIG"));
249 ////////////////////////////////////////////////////////////////////////////
255 ###########################################################################
257 ###########################################################################
261 macro=$ALIRUN_TMPDIR/Digitize.C
265 ////////////////////////////////////////////////////////////////////////////
268 gAlice->OpenBaseFile("update");
270 if (gAlice) delete gAlice;
272 AliRun *gAlice = (AliRun*)gDirectory->Get("gAlice");
274 gAlice->$mode(gSystem->Getenv("CONFIG_DETECTOR"));
276 ////////////////////////////////////////////////////////////////////////////
282 ###########################################################################
284 ###########################################################################
289 if [ -d ../man/man4 ]
297 ###########################################################################
299 ###########################################################################
304 ###########################################################################
306 ###########################################################################
311 ###########################################################################
313 ###########################################################################
315 if [ "$DETECTORS" = "" ]
319 for det in $DETECTORS
321 CONFIG_DETECTOR=$det; export CONFIG_DETECTOR
322 if [ "$FORK" = "TRUE" ]
324 if [ "$LSF_FORK" = "TRUE" ]
326 lsrun AliRoot Digits $CONFIG_DETECTOR
328 AliRoot Digits $CONFIG_DETECTOR &
331 AliRoot Digits $CONFIG_DETECTOR
340 ###########################################################################
342 ALL="MUON RICH TOF ITS TPC PHOS PMD CASTOR ZDC TRD"; export ALL
343 DETECTORS=""; export DETECTORS
344 CONFIG_FILE="galice.root"; export CONFIG_FILE
345 CONFIG=$ALICE_ROOT/macros/Config.C; export CONFIG
346 CONFIG_NPARTICLES=50; export CONFIG_NPARTICLES
347 CONFIG_PATH=`pwd`; export CONFIG_PATH
349 ALIRUN_TMPDIR=`Mktemp`; export ALIRUN_TMPDIR
360 if [ -x /usr/local/lsf/bin/lsrun ]
365 for config in $CONFIG_PATH/Config.C $ALICE_ROOT/macros/Config.C
369 CONFIG=$config; export CONFIG
415 if [ "$list" = "all" ]
419 DETECTORS=`echo $list | sed 's/+/ /g'`
432 CONFIG_SPLIT_FILE="TRUE"; export CONFIG_SPLIT_FILE
436 CONFIG_FILE=$1; export CONFIG_FILE
444 CONFIG_NPARTICLES=$1; export CONFIG_NPARTICLES
448 CONFIG_SEED=$1; export CONFIG_SEED
457 CONFIG=$1; export CONFIG
466 if [ `dirname $OUTPUT` = "." ]
471 [ ! -d $OUTPUT ] && mkdir -p $OUTPUT
472 [ ! -d $ALIRUN_TMPDIR ] && mkdir -p $ALIRUN_TMPDIR
480 case `type -t AliRun$cmd` in