From: hristov Date: Fri, 26 Jan 2001 21:22:02 +0000 (+0000) Subject: Major upgrade of AliRoot code X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=e0381e2291faf1320eaa3ccc02d1f14812c5520a Major upgrade of AliRoot code --- diff --git a/share/alirun b/share/alirun new file mode 100755 index 00000000000..dd6066ffe24 --- /dev/null +++ b/share/alirun @@ -0,0 +1,484 @@ +#!/bin/sh +############################################################################# +# alirun - a shell script to run AliRoot +############################################################################# +# +# modification history +# $Log$ +# +# SYNOPSIS +# alirun [[-d |-all]] +# [-f ] +# [-o ] +# [-split] +# [-C ] +# [-p ] +# [-seed ] +# [-n ] +# <-c > +# +# DESCRIPTION +# This script is a wrapper for AliRoot and provides a command line interface suitable for running in batch mode. +# +# CONFIGURATION OPTIONS +# The following options are used to configure AliRoot session. +# +# -c +# 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: +# +# - Hits ................ simulation +# - Digits .............. digitisation +# - SDigits ............. creation of sumable digits +# - SDigits2Digits ...... conversion SDigits->Digits +# +# -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. +# +# -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. +# +# -split +# If specified, this option will tell AliRoot to divert branches of Root trees into separate files. +# +# The layout of output directory is the following: +# +# +# |-- Digits..root +# |-- SDigits..root +# |-- Hits.root +# |-- Kine.root +# |-- Reco.root +# `-- galice.root +# +# -C +# An alternative to Config.C macro which contains AliRoot configuration. +# +# -p +# 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. +# +# -seed +# Seed for random number generator (used to initialise TRandom3(n)). +# +# -n +# Number of events to generate (not yet implemented). +# +# RUN OPTIONS +# These options define run time appearance of the AliRoot session. +# +# -help +# Display usage. +# +# -verbose +# Switch verbose screen output on. +# +# -quiet +# Switch verbose output off. Output is redirected to a file which is shown on standard output only if returns non zero status. +# +# -fork +# 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. +# +# -trace +# Show trace of execution of shell commands. +# +# -debug +# Execute AliRoot under gdb. +# +# -break +# Execute AliRoot under gdb and set . +# +# -makeman +# 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: +# +# alirun -o /tmp/event.1 -f test.root -p 100 -verbose -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: +# +# alirun -o /tmp/event.2 -split -p 100 -verbose -c Hits +# +# Use output from first step and create TOF and RICH 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 +# +# 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 +# +# AUTHOR: +# Predrag Buncic, e-mail: Predrag.Buncic@cern.ch +# +# CREATION DATE: +# 06-Nov-2000 +# +#C< +########################################################################### + +########################################################################### +AliRun() +########################################################################### +{ + printf "Usage: alirun [[-d |-all]]\n" + printf " [-f ]\n" + printf " [-o ]\n" + printf " [-split]\n" + printf " [-C ]\n" + printf " [-p ]\n" + printf " [-seed ]\n" + printf " [-n event #]\n" + printf " <-c >\n" + exit +} + +########################################################################### +Mktemp() +########################################################################### +{ + mktemp -qu /tmp/alirun.$$.XXXXXX +} + +########################################################################### +Cleanup() +########################################################################### +{ + if [ -d $ALIRUN_TMPDIR ] + then + rm -rf $ALIRUN_TMPDIR + fi +} + +########################################################################### +AliRoot() +########################################################################### +{ + case $1 in + Hits) + macro=`HitsMacro` + ;; + Digits) + macro=`DigitsMacro Hits2Digits` + ;; + SDigits) + macro=`DigitsMacro Hits2SDigits` + ;; + SDigits2Digits) + macro=`DigitsMacro SDigits2Digits` + ;; + *.C|*.C\(*\)) + macro=$1 + ;; + *) + printf "Unknown command: %s. Terminating...\n" $1 + exit 255 + ;; + esac + + if [ "$2" != "" ] + then + CONTEXT="<"$2">" + else + CONTEXT="<"None">" + fi + + stdout=$ALIRUN_TMPDIR/STDOUT.$${$CONTEXT} + + hr="========================================" + + if [ "$VERBOSE" = "FALSE" ] + then + printf "%s\n+ aliroot -q -b %s %s\n%s\n" $hr$hr $1 $CONTEXT $hr$hr + fi > $stdout + + if [ "$DEBUG" = "TRUE" ] + then + cat<$ALIRUN_TMPDIR/gdb +b main +r -q -b $macro +disable breakpoints +b $BREAK +c +where +EOF + $ECHO gdb -q -x $ALIRUN_TMPDIR/gdb aliroot + else + if [ "$VERBOSE" = "TRUE" ] + then + $ECHO aliroot -q -b $macro + else + $ECHO aliroot -q -b $macro > $stdout 2>&1 + if [ $? -ne 0 ] + then + echo "- "aliroot -q -b " "$1" "$CONTEXT + cat $stdout + exit + else + echo "+ "aliroot -q -b " "$1" "$CONTEXT + fi + fi + fi + +} + + +########################################################################### +HitsMacro() +########################################################################### +{ + macro=$ALIRUN_TMPDIR/Simulate.C + + cat < $macro + +//////////////////////////////////////////////////////////////////////////// +void Simulate() +{ + gAlice->Init(gSystem->Getenv("CONFIG")); + + gAlice->Run(1); +} +//////////////////////////////////////////////////////////////////////////// + +EOF + echo $macro +} + +########################################################################### +DigitsMacro() +########################################################################### +{ + mode=$1 + + macro=$ALIRUN_TMPDIR/Digitize.C + + cat < $macro + +//////////////////////////////////////////////////////////////////////////// +void Digitize() +{ + gAlice->OpenBaseFile("update"); + + if (gAlice) delete gAlice; + + AliRun *gAlice = (AliRun*)gDirectory->Get("gAlice"); + + gAlice->$mode(gSystem->Getenv("CONFIG_DETECTOR")); +} +//////////////////////////////////////////////////////////////////////////// + +EOF + echo $macro +} + +########################################################################### +AliRunMakeman() +########################################################################### +{ + mangen -n tool $0 + if [ $? -eq 0 ] + then + if [ -d ../man/man4 ] + then + mv $0.? ../man/man4 + fi + fi + exit +} + +########################################################################### +AliRunMacro() +########################################################################### +{ + AliRoot $* +} + +########################################################################### +AliRunHits() +########################################################################### +{ + AliRoot Hits +} + +########################################################################### +AliRunDigits() +########################################################################### +{ + if [ "$DETECTORS" = "" ] + then + AliRoot Digits + else + for det in $DETECTORS + do + export CONFIG_DETECTOR=$det; + if [ "$FORK" = "TRUE" ] + then + if [ "$LSF_FORK" = "TRUE" ] + then + lsrun AliRoot Digits $CONFIG_DETECTOR + else + AliRoot Digits $CONFIG_DETECTOR & + fi + else + AliRoot Digits $CONFIG_DETECTOR + fi + done + wait + fi +} + + + +########################################################################### + +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` + +export ALIRUN_TMPDIR=`Mktemp` + +DEBUG="FALSE" +BREAK="" +VERBOSE="TRUE" +OUTPUT=. +CMDLIST="Usage" +FORK="FALSE" +FORK_LSF="FALSE" +ECHO="" + +if [ -x /usr/local/lsf/bin/lsrun ] +then + FORK_LSF="TRUE" +fi + +for config in $CONFIG_PATH/Config.C $ALICE_ROOT/macros/Config.C +do + if [ -f $config ] + then + export CONFIG=$config + break + fi +done + +for param in $* +do + case $param in + -debug) + shift 1 + DEBUG="TRUE" + ;; + -break) + shift 1 + DEBUG="TRUE" + BREAK=$1 + ;; + -trace) + shift 1 + set -vx + ;; + -echo) + shift 1 + ECHO="echo " + ;; + -verbose) + shift 1 + VERBOSE="TRUE" + ;; + -quiet) + shift 1 + VERBOSE="FALSE" + ;; + -help) + AliRun + ;; + -makeman) + AliRunMakeman + ;; + -fork) + shift 1 + FORK="TRUE" + ;; + -d) + shift 1 + list=$1 + if [ "$list" = "all" ] + then + DETECTORS=$ALL + else + DETECTORS=`echo $list | sed 's/+/ /g'` + fi + ;; + -all) + shift 1 + DETECTORS=$ALL + ;; + -o) + shift 1 + OUTPUT=$1 + ;; + -split) + shift 1 + export CONFIG_SPLIT_FILE="TRUE" + ;; + -f) + shift 1 + export CONFIG_FILE=$1 + ;; + -n) + shift 1 + NEVENTS=$1 + ;; + -p) + shift 1 + export CONFIG_NPARTICLES=$1 + ;; + -seed) + shift 1 + export CONFIG_SEED=$1 + ;; + -c) + shift 1 + CMDLIST=$* + break + ;; + -C) + shift 1 + export CONFIG=$1 + ;; + *) + shift 1 + ;; + esac +done + + +if [ `dirname $OUTPUT` = "." ] +then + OUTPUT=`pwd`/$OUTPUT +fi + +[ ! -d $OUTPUT ] && mkdir -p $OUTPUT +[ ! -d $ALIRUN_TMPDIR ] && mkdir -p $ALIRUN_TMPDIR + +trap Cleanup 2 + +( + cd $OUTPUT + for cmd in $CMDLIST + do + case `type -t AliRun$cmd` in + function) + shift 1 + AliRun$cmd $* + ;; + *) + ;; + esac + done +) + +Cleanup \ No newline at end of file diff --git a/share/mangen b/share/mangen new file mode 100755 index 00000000000..d767881cc3b --- /dev/null +++ b/share/mangen @@ -0,0 +1,689 @@ +#!/bin/sh +# +# mangen - generate manual entries for library +# +# modification history +# 02g,16jul93,abh Added compatibility for FORTRAN "C" style comments. See +# STAR programming guidelines for template. +# 02f,08may90,jdi nroff lines: took out colrm, added tbl and -Tlp. +# 02e,12mar90,jdi made NOMANUAL work for module entries; +# added CS/CE macros to routine declarations in lib synopsis. +# 02d,25jan90,rbr works with "#!/bin/awk -f" and the like +# 02c,10apr89,dnw changed to always put individual routine manual entries in +# chapter 2 instead of in (summary chapter + 1), so driver +# routines end up in 2 rather than 4. +# 02b,05apr89,dnw removed NOT_GENERIC filter +# added removing of mg.out and mgr.out before starting +# 02a,05nov87,jlf changed to allow mangen'ing of scripts +# changed so routine definitions that don't fit on one +# one line, have a '...' appended in synopses. +# changed documentation format so mangen can be mangen'ed. +# +# +# SYNOPSIS +# mangen [-d] [-n] [-l] chapter file +# +# DESCRIPTION +# generates: . (manual entry for module) +# and if "-l": . (manual entries for each routine) +# +# where is the "root" of the "tail" of the specified file +# (i.e. if file="/usr/dave/gronk.c", then name="gronk"); +# and is the single digit chapter number +# (i.e. just the specified chapter number if one was given, +# or the number from the table below if a chapter name was given). +# +# can be any digit or any of the following chapter abbreviations: +# +# # abbr name what +# = ==== =========== ==================================== +# 0 con* +# over* conventions - conventions and overview material +# 1 lib* libraries - subroutine library summaries +# 2 routines - individual library routines +# 3 task* +# tsk* +# dr* drivers - tasks and drivers +# 4 tool* tools - Unix development/maintenence tools +# +# NOTE: Specifying the chapter as "lib" automatically selects the -l option. +# +# "-l" flag causes a special library module style manual entry to be created. +# The manual entry for a library has a specially constructed synopsis section +# that contains the titles and calling sequence of each routine in the library. +# Also a seperate manual entry is generated for each of the routines in the +# library. These routine manual entries will be put in a file named libxxx.2. +# +# "-d" flag causes the intermediate nroff source files to NOT be deleted. +# These are called "mg.out" and "mgr.out" for the module manual entry +# and individual routine entries (only if -l option specified), respectively. +# This option is useful for debugging manual entries that don't look the +# way you expected. +# +# "-n" flag causes nroff sources not to be deleted, and not to be nroffed +# either. In this case, "mg.out" (and "mgr.out") will be the ONLY output +# from mangen. +# +# EXAMPLE: +# % mangen lib /usr/vw/lib/lstlib.c +# will create "lstlib.1" and "liblst.2" in the current directory. +#C< + +trap "rm -f mg.out mgr.out /tmp/mangen$$; exit" 1 2 3 15 + +rm -f mg.out mgr.out # start with a clean slate + +# set home to directory that contains this script + +home=`expr $0 : '\(.*/\)[^/]' '|' ./` + +dontdelete=0 +dontnroff=0 +lib=0 +chapter=0 + +while (test $# -gt 1) +do + case "$1" in + -d) dontdelete=1 ;; + -l) lib=1 ;; + -n) dontdelete=1; dontnroff=1 ;; + [0-9]) chapter=$1 ;; + con* | over*) chapter=0 ;; + lib*) chapter=1; lib=1 ;; + task* | tsk* | dr*) chapter=3 ;; + tool*) chapter=4 ;; + *) echo "flag not recognized:" $1; exit 1 ;; + esac + shift +done + +# remove path + +name=`basename $1` + +# remove trailing component, eg. ".xx" + +section=`expr $name : '\(.*\)\..*' '|' $name` + +# create awk program found at end of this script, and +# make substitutions in the awk program source + +awk '/^#START_AWK$/,/^#STOP_AWK$/' <$0 | \ +sed -e "s^\%filename^$name^g" \ + -e "s/\%chapter/$chapter/g" \ + -e "s/\%lib/$lib/" \ + >/tmp/mangen$$ + +# generate the nroff source of the manual entries + +awk -f /tmp/mangen$$ <$1 + +rm /tmp/mangen$$ + +# nroff them unless -n option + +if (test $dontnroff -eq 0) then + #tbl mg.out | nroff -man -Tman >$section.$chapter + #tbl mg.out | nroff -man -Tlp >$section.$chapter + #tbl mg.out | nroff -mangen -Tlp >$section.$chapter + tbl mg.out | nroff >$section.$chapter +else + mv mg.out $section.$chapter +fi + +if (test $lib -eq 1) then + if (test $dontnroff -eq 0) then + #tbl mgr.out | nroff -man -Tman >$section.2 + #tbl mgr.out | nroff -mangen -Tlp >$section.2 + tbl mgr.out | nroff >$section.2 + else + mv mgr.out $section.2 + fi +fi +# delete the nroff source, unless -d or -n option + +if (test $dontdelete -eq 0) then + rm -f mg.out mgr.out +fi + +exit 0 + +#START_AWK + +# mangen.awk - awk program to generate manual entries + +# the variable "s" holds the current state of the scan: +# +# title - get title line (initial state +# mh0 - skip to start of modification history +# mh - skip to end of modification history +# desc0 - skip to start of module description +# desc - process module description +# +# the following additional states are used if the "lib" flag is specified: +# +# rtn - skip to start of next routine +# rtitle - skip to, and process, routine title line +# rdesc - skip to, and process, routine description +# rsy0 - skip to start of routine synopsis +# rsy - process routine synopsis + + +BEGIN { + blanks = " " + + # the following values preceded by a "%" are substituted + # for by a "sed" program + + filename = "%filename" # source filename + chapter = %chapter # chapter number + lib = %lib # 1 = make routine entries, 0 = don't + + # initialize + + dbg = 0 # 1 = output debug stuff + s = "title" # initial state + + # get module name w/o the extension and the output file names + + dot = index (filename, ".") + + if (dot == 0) + modname = filename + else + modname = substr (filename, 1, dot - 1) + + outfile = "mg.out" + rtnfile = "mgr.out" + } + +dbg == 1 { + print s "\n" $0 >outfile + } + +# ignore lint directive lines + +/LINTLIBRARY/ {next} +/ARGSUSED/ {next} +/VARARGS/ {next} + +# get ss = line without leading '/* ' or '* ' or '# ' and trailing '*/' +# subhead = subheading (all caps at beginning of line w/ optional ':') +# subheadl = remainder of subheading line following ':' + + { + # detab line + + nf = split ($0, words, "\t") + + if (nf == 0) + l = "" + else + { + l = words[1] + + for (i = 2; i <= nf; i++) + l = l substr(" ", 1, 8-(length(l) % 8)) words[i] + } + + # strip off leading and trailing comment indicators + + if ((l ~ /^C>/) || (l ~ /^\/\*/)) + { + if ((l ~ /^C> /) || (l ~ /^\/\* /)) + start = 4 + else + start = 3 + } + else if ((l ~ /^C/) || (l ~ /^\*/)) + { + if ((l ~ /^C /) || (l ~ /^\* /)) + start = 3 + else + start = 2 + } + else if (l ~ /^\#/) + { + if (l ~ /^\# /) + start = 3 + else + start = 2 + } + else + start = 1 + + end = length (l) + + if ((l ~ /C<$/) || (l ~ /\*\/$/)) + end = end - 2 + + ss = substr (l, start, end - start + 1) + + + # check for sub heading line + + if ((ss !~ /^[A-Z][^a-z]*:/) && \ + (ss !~ /^[A-Z][^a-z]*$/)) + subhead = "" + else + { + colon = index (ss, ":") + + if (colon == 0) + { + subhead = ss + subheadl = "" + } + else + { + subhead = substr (ss, 1, colon - 1) + + subheadl = substr (ss, colon + 2) + if (subheadl ~ /^ *$/) + subheadl = "" + } + } + } + +# get module name and title: 1st line in file + +s == "title" { + # This gets rid of .yacc first lines ("%{"), and the first + # line or two of a script ("#!/bin/sh", etc.). + + if (NF == 1 || index($1, "#!")) + next + + # check that title matches module name + + dot = index ($2, ".") + if (dot == 0) + titlename = $2 + else + titlename = substr (ss, 1, dot - 1) + + if (titlename != modname) + { + print "ERROR: on line " NR \ + ": module name inconsistent w/ file name." + exit + } + + title = ss + + s = "mh0" + next + } + +# skip modification history: skip, looking for 'modification history' then blank + +s == "mh0" { + if (l ~ /modification history/) + s = "mh" + next + } + +s == "mh" { + if (ss ~ /^ *$/) + { + s = "desc0" + xdesc = 0 + } + next + } + +# get module description: ignore leading blank lines; turn capital lines +# into subheadings; accumulate rest looking for '*/' + +s == "desc0" { + if (l !~ /^ *$/) + { + ignore = 0 + s = "desc" + } + } + +s == "desc" { + # suppress manual entry if NOMANUAL specified + + if (l ~ /NO[ _-]?MANUAL/) + { + ignorelib = 1 + } + + # check for end of description section + + if ((l ~ /^\#*C maxlen) + maxlen = len + + # note minimum gap between code and comment + + if ((ic != 0) && (is != 0)) + { + gap = ic - is - 1 + i - 5 + if (gap < mingap) + mingap = gap + } + } + else + { + # end of synopsis reached; output routine name, then + # manual for this routine, then form-feed + + s = "rtn" + + print rnm >rtnfile + stitle [++xrtn] = rtitle + ssy [xrtn] = rsy[1] + + # print name and title + + print ".TH " rnm " 2" \ + " \"\" \"ALICE Reference Manual\"" >rtnfile + print ".ad b" >rtnfile + print ".SH NAME\n" rtitle >rtnfile + + # print routine synopsis + + # figure out if we should squeeze decls and comments + + squeeze = 0 + if (maxlen > 60) + { + squeeze = maxlen - 60 + if (squeeze > (mingap - 1)) + squeeze = mingap - 1 + } + + print ".SH SYNOPSIS" >rtnfile + print ".CS" >rtnfile + print ".nf" >rtnfile + print rsy[1] >rtnfile + for (i = 2; i <= xrsy; i++) + { + if (rsyc[i] == "") + n = 0 + else + n = rsyci[i] - length(rsy[i]) - 5 - squeeze + print " " rsy[i] substr(blanks,0,n) rsyc[i] >rtnfile + } + print ".fi" >rtnfile + print ".CE" >rtnfile + + # print description + + if ((xrdesc != 0) && (rdesc[1] !~ /^\.SH/)) + print ".SH DESCRIPTION" >rtnfile + + seealso = 0 + + for (i = 1; i <= xrdesc; i++) + { + print rdesc[i] >rtnfile + + if (rdesc[i] ~ /^.SH SEE ALSO/) + { + print modname "(" chapter ")," >rtnfile + seealso = 1 + } + } + + # print see also if not already done above + + if (seealso == 0) + { + print ".SH SEE ALSO" >rtnfile + print modname "(" chapter ")" >rtnfile + } + # form-feed + + print " " >rtnfile + } + + next + } + +# end of file: output module manual + +END { + if (!ignorelib) + { + # print name and title + + print ".TH " modname " " chapter \ + " \"\" \"ALICE Reference Manual\"" >outfile + print ".ad b" >outfile + print ".SH NAME\n" title >outfile + + + # print specially constructed synopsis, if library + # If no routines, say so. + + if (lib == 1) + { + print ".SH SYNOPSIS" >outfile + print ".nf" >outfile + for (i = 1; i <= xrtn; i++) + print stitle[i] >outfile + print "" >outfile + if (xrtn == 0) + print "NO CALLABLE ROUTINES" >outfile + print ".CS" >outfile + for (i = 1; i <= xrtn; i++) + { + if (substr(ssy[i], length (ssy[i])) == ")") + print ssy[i] >outfile + else + print ssy[i], "..." >outfile + } + print ".CE" >outfile + print ".fi" >outfile + } + + + # print module description + + if ((xdesc != 0) && (desc[1] !~ /^\.SH/)) + print ".SH DESCRIPTION" >outfile + for (i = 1; i <= xdesc; i++) + print desc[i] >outfile + } + } +#STOP_AWK