]> git.uio.no Git - u/mrichter/AliRoot.git/blame - share/alirun
New thicknesses (300+300 um) added for SPD chips and detectors and set as default...
[u/mrichter/AliRoot.git] / share / alirun
CommitLineData
572784b9 1#!/usr/local/bin/bash
e0381e22 2#############################################################################
3# alirun - a shell script to run AliRoot
4#############################################################################
5#
6# modification history
7# $Log$
572784b9 8# Revision 1.2 2001/02/01 17:46:26 buncic
9# Fixed mktemp on HP and Sun
10#
da41e58d 11# Revision 1.1 2001/01/26 21:22:02 hristov
12# Major upgrade of AliRoot code
13#
e0381e22 14#
15# SYNOPSIS
16# alirun [[-d <TPC+ITS+..>|-all]]
17# [-f <hits file>]
18# [-o <output directory>]
19# [-split]
20# [-C <Config.C>]
21# [-p <particle#>]
22# [-seed <seed for random number generator>]
23# [-n <event #>]
24# <-c <command ...>>
25#
26# DESCRIPTION
27# This script is a wrapper for AliRoot and provides a command line interface suitable for running in batch mode.
28#
29# CONFIGURATION OPTIONS
30# The following options are used to configure AliRoot session.
31#
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:
34#
35# - Hits ................ simulation
36# - Digits .............. digitisation
37# - SDigits ............. creation of sumable digits
38# - SDigits2Digits ...... conversion SDigits->Digits
39#
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.
42#
43# -f <file>
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.
45#
46# -o <directory>
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.
48#
49# -split
50# If specified, this option will tell AliRoot to divert branches of Root trees into separate files.
51#
52# The layout of output directory is the following:
53#
54# <directory>
55# |-- Digits.<detector>.root
56# |-- SDigits.<detector>.root
57# |-- Hits.root
58# |-- Kine.root
59# |-- Reco.root
60# `-- galice.root
61#
62# -C <macro.C>
63# An alternative to Config.C macro which contains AliRoot configuration.
64#
65# -p <n>
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.
67#
68# -seed <n>
69# Seed for random number generator (used to initialise TRandom3(n)).
70#
71# -n <n>
72# Number of events to generate (not yet implemented).
73#
74# RUN OPTIONS
75# These options define run time appearance of the AliRoot session.
76#
77# -help
78# Display usage.
79#
80# -verbose
81# Switch verbose screen output on.
82#
83# -quiet
84# Switch verbose output off. Output is redirected to a file which is shown on standard output only if <command> returns non zero status.
85#
86# -fork
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.
88#
89# -trace
90# Show trace of execution of shell commands.
91#
92# -debug
93# Execute AliRoot under gdb.
94#
95# -break <breakpoint>
96# Execute AliRoot under gdb and set <breakpoint>.
97#
98# -makeman
99# Create man page for alirun.
100#
101# EXAMPLES
102# Run sumulation for 1 event, 100 particles and store output in file test.root in /tmp/event.1 directory:
103#
104# alirun -o /tmp/event.1 -f test.root -p 100 -verbose -c Hits
105#
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:
107#
108# alirun -o /tmp/event.2 -split -p 100 -verbose -c Hits
109#
110# Use output from first step and create TOF and RICH digits. Output is in the same direcory and in file test.root
111#
112# alirun -d TOF+RICH -o /tmp/event.1 -f test.root -verbose -c Digits
113#
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:
115#
116# alirun -d all -o /tmp/event.2 -split -verbose -c Digits
117#
118# AUTHOR:
119# Predrag Buncic, e-mail: Predrag.Buncic@cern.ch
120#
121# CREATION DATE:
122# 06-Nov-2000
123#
124#C<
125###########################################################################
126
127###########################################################################
128AliRun()
129###########################################################################
130{
131 printf "Usage: alirun [[-d <TPC+ITS+..>|-all]]\n"
132 printf " [-f <hits file>]\n"
133 printf " [-o <output directory>]\n"
134 printf " [-split]\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"
140 exit
141}
142
143###########################################################################
144Mktemp()
145###########################################################################
146{
da41e58d 147# mktemp -qu /tmp/alirun.$$.XXXXXX
148 echo /tmp/alirun.$$.
e0381e22 149}
150
151###########################################################################
152Cleanup()
153###########################################################################
154{
155 if [ -d $ALIRUN_TMPDIR ]
156 then
157 rm -rf $ALIRUN_TMPDIR
158 fi
159}
160
161###########################################################################
162AliRoot()
163###########################################################################
164{
165 case $1 in
166 Hits)
167 macro=`HitsMacro`
168 ;;
169 Digits)
170 macro=`DigitsMacro Hits2Digits`
171 ;;
172 SDigits)
173 macro=`DigitsMacro Hits2SDigits`
174 ;;
175 SDigits2Digits)
176 macro=`DigitsMacro SDigits2Digits`
177 ;;
178 *.C|*.C\(*\))
179 macro=$1
180 ;;
181 *)
182 printf "Unknown command: %s. Terminating...\n" $1
183 exit 255
184 ;;
185 esac
186
187 if [ "$2" != "" ]
188 then
189 CONTEXT="<"$2">"
190 else
191 CONTEXT="<"None">"
192 fi
193
194 stdout=$ALIRUN_TMPDIR/STDOUT.$${$CONTEXT}
195
196 hr="========================================"
197
198 if [ "$VERBOSE" = "FALSE" ]
199 then
200 printf "%s\n+ aliroot -q -b %s %s\n%s\n" $hr$hr $1 $CONTEXT $hr$hr
201 fi > $stdout
202
203 if [ "$DEBUG" = "TRUE" ]
204 then
205 cat<<EOF>$ALIRUN_TMPDIR/gdb
206b main
207r -q -b $macro
208disable breakpoints
209b $BREAK
210c
211where
212EOF
213 $ECHO gdb -q -x $ALIRUN_TMPDIR/gdb aliroot
214 else
215 if [ "$VERBOSE" = "TRUE" ]
216 then
217 $ECHO aliroot -q -b $macro
218 else
219 $ECHO aliroot -q -b $macro > $stdout 2>&1
220 if [ $? -ne 0 ]
221 then
222 echo "- "aliroot -q -b " "$1" "$CONTEXT
223 cat $stdout
224 exit
225 else
226 echo "+ "aliroot -q -b " "$1" "$CONTEXT
227 fi
228 fi
229 fi
230
231}
232
233
234###########################################################################
235HitsMacro()
236###########################################################################
237{
238 macro=$ALIRUN_TMPDIR/Simulate.C
239
240 cat <<EOF> $macro
241
242////////////////////////////////////////////////////////////////////////////
243void Simulate()
244{
245 gAlice->Init(gSystem->Getenv("CONFIG"));
246
247 gAlice->Run(1);
248}
249////////////////////////////////////////////////////////////////////////////
250
251EOF
252 echo $macro
253}
254
255###########################################################################
256DigitsMacro()
257###########################################################################
258{
259 mode=$1
260
261 macro=$ALIRUN_TMPDIR/Digitize.C
262
263 cat <<EOF> $macro
264
265////////////////////////////////////////////////////////////////////////////
266void Digitize()
267{
268 gAlice->OpenBaseFile("update");
269
270 if (gAlice) delete gAlice;
271
272 AliRun *gAlice = (AliRun*)gDirectory->Get("gAlice");
273
274 gAlice->$mode(gSystem->Getenv("CONFIG_DETECTOR"));
275}
276////////////////////////////////////////////////////////////////////////////
277
278EOF
279 echo $macro
280}
281
282###########################################################################
283AliRunMakeman()
284###########################################################################
285{
286 mangen -n tool $0
287 if [ $? -eq 0 ]
288 then
289 if [ -d ../man/man4 ]
290 then
291 mv $0.? ../man/man4
292 fi
293 fi
294 exit
295}
296
297###########################################################################
298AliRunMacro()
299###########################################################################
300{
301 AliRoot $*
302}
303
304###########################################################################
305AliRunHits()
306###########################################################################
307{
308 AliRoot Hits
309}
310
311###########################################################################
312AliRunDigits()
313###########################################################################
314{
315 if [ "$DETECTORS" = "" ]
316 then
317 AliRoot Digits
318 else
319 for det in $DETECTORS
320 do
da41e58d 321 CONFIG_DETECTOR=$det; export CONFIG_DETECTOR
e0381e22 322 if [ "$FORK" = "TRUE" ]
323 then
324 if [ "$LSF_FORK" = "TRUE" ]
325 then
326 lsrun AliRoot Digits $CONFIG_DETECTOR
327 else
328 AliRoot Digits $CONFIG_DETECTOR &
329 fi
330 else
331 AliRoot Digits $CONFIG_DETECTOR
332 fi
333 done
334 wait
335 fi
336}
337
338
339
340###########################################################################
341
da41e58d 342ALL="MUON RICH TOF ITS TPC PHOS PMD CASTOR ZDC TRD"; export ALL
343DETECTORS=""; export DETECTORS
344CONFIG_FILE="galice.root"; export CONFIG_FILE
345CONFIG=$ALICE_ROOT/macros/Config.C; export CONFIG
346CONFIG_NPARTICLES=50; export CONFIG_NPARTICLES
347CONFIG_PATH=`pwd`; export CONFIG_PATH
e0381e22 348
da41e58d 349ALIRUN_TMPDIR=`Mktemp`; export ALIRUN_TMPDIR
e0381e22 350
351DEBUG="FALSE"
352BREAK=""
353VERBOSE="TRUE"
354OUTPUT=.
355CMDLIST="Usage"
356FORK="FALSE"
357FORK_LSF="FALSE"
358ECHO=""
359
360if [ -x /usr/local/lsf/bin/lsrun ]
361then
362 FORK_LSF="TRUE"
363fi
364
365for config in $CONFIG_PATH/Config.C $ALICE_ROOT/macros/Config.C
366do
367 if [ -f $config ]
368 then
da41e58d 369 CONFIG=$config; export CONFIG
e0381e22 370 break
371 fi
372done
373
374for param in $*
375do
376 case $param in
377 -debug)
378 shift 1
379 DEBUG="TRUE"
380 ;;
381 -break)
382 shift 1
383 DEBUG="TRUE"
384 BREAK=$1
385 ;;
386 -trace)
387 shift 1
388 set -vx
389 ;;
390 -echo)
391 shift 1
392 ECHO="echo "
393 ;;
394 -verbose)
395 shift 1
396 VERBOSE="TRUE"
397 ;;
398 -quiet)
399 shift 1
400 VERBOSE="FALSE"
401 ;;
402 -help)
403 AliRun
404 ;;
405 -makeman)
406 AliRunMakeman
407 ;;
408 -fork)
409 shift 1
410 FORK="TRUE"
411 ;;
412 -d)
413 shift 1
414 list=$1
415 if [ "$list" = "all" ]
416 then
417 DETECTORS=$ALL
418 else
419 DETECTORS=`echo $list | sed 's/+/ /g'`
420 fi
421 ;;
422 -all)
423 shift 1
424 DETECTORS=$ALL
425 ;;
426 -o)
427 shift 1
428 OUTPUT=$1
429 ;;
430 -split)
431 shift 1
da41e58d 432 CONFIG_SPLIT_FILE="TRUE"; export CONFIG_SPLIT_FILE
e0381e22 433 ;;
434 -f)
435 shift 1
da41e58d 436 CONFIG_FILE=$1; export CONFIG_FILE
e0381e22 437 ;;
438 -n)
439 shift 1
440 NEVENTS=$1
441 ;;
442 -p)
443 shift 1
da41e58d 444 CONFIG_NPARTICLES=$1; export CONFIG_NPARTICLES
e0381e22 445 ;;
446 -seed)
447 shift 1
da41e58d 448 CONFIG_SEED=$1; export CONFIG_SEED
e0381e22 449 ;;
450 -c)
451 shift 1
452 CMDLIST=$*
453 break
454 ;;
455 -C)
456 shift 1
da41e58d 457 CONFIG=$1; export CONFIG
e0381e22 458 ;;
459 *)
460 shift 1
461 ;;
462 esac
463done
464
465
466if [ `dirname $OUTPUT` = "." ]
467then
468 OUTPUT=`pwd`/$OUTPUT
469fi
470
471[ ! -d $OUTPUT ] && mkdir -p $OUTPUT
472[ ! -d $ALIRUN_TMPDIR ] && mkdir -p $ALIRUN_TMPDIR
473
474trap Cleanup 2
475
476(
477 cd $OUTPUT
478 for cmd in $CMDLIST
479 do
480 case `type -t AliRun$cmd` in
481 function)
482 shift 1
483 AliRun$cmd $*
484 ;;
485 *)
486 ;;
487 esac
488 done
489)
490
491Cleanup