2 #############################################################################
3 # rec.sh. Front-end script to run reconstruction from the grid chunks
5 # ./rec.sh <run_number>
6 #############################################################################
9 # version 1.0 2008/03/04 02:12 Marco Meoni
11 # version 1.1 2008/03/28 00:33 Marco Meoni. Used aliensh instead of alien client
13 # SET THE FOLLOWING PARAMETERS IF NEEDED:
14 # ---------------------------------------
16 DIALOG=${DIALOG=dialog}
17 GSHELL_ROOT=$ALIEN_ROOT/api
18 PATH=$PATH:$GSHELL_ROOT/bin
19 # ---------------------------------------
23 [ -z $RUNNUM ] && { echo "Please provide a run number..."; exit 1; }
25 [ ! -e "$HOME/.globus/usercert.pem" ] && { echo "FAILED: There is no certificate in $HOME/.globus"; exit 1; }
27 [ -e "/tmp/gclient_env_$UID" ] && { source /tmp/gclient_env_$UID; }
30 [ ! "$?" -eq "0" ] && { echo "FAILED: Token creation failed"; exit 1; }
33 TITLE="Standalone reconstruction of Grid rawdata chunks. v$VERSION"
35 # Retrieve the list of chunks from AliEn.......
36 BASEDIR="/alice/data/20"$YEAR
37 PATTERN="/raw/"$YEAR"0000"$RUNNUM"*0.root"
38 aliensh -c "gbbox find $BASEDIR $PATTERN" | head --lines=-1 > collection.tmp
40 [ $(stat -c%s collection.tmp) -eq 0 ] && { echo "No chunks found for the given run"; exit 1; }
41 list=`cat collection.tmp | awk '{printf("%s %s %s ",$1," .","0");}'` # improve: put basename
42 totChunks=`cat collection.tmp | wc -l`; totChunks=`echo \($totChunks / 3\) | bc`
45 tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
46 trap "rm -f $tempfile" 0 1 2 5 15
47 $DIALOG --clear --no-cancel --title "$TITLE" \
48 --ok-label OK --checklist "$totChunks chunks available. Select chunks for reconstruction" 18 74 10 \
51 CHUNKS=`cat $tempfile`" ."
52 echo "Selected chunks:"
56 echo $CHUNKS | while read -d " " filename; do
57 filename=${filename//\"/}
58 CHUNK=`echo $filename | cut -d "/" -f 8 | cut -d "." -f 1,2 | cut -c 12-14,16-`
60 echo "Running AliRoot reconstruction for chunk $filename. Outputs will be stored in "$RUNNUM"/"$CHUNK"."
61 rm -rf $RUNNUM"/"$CHUNK
62 mkdir -p $RUNNUM"/"$CHUNK
64 aliroot -b -q ../../rec.C\(\"alien://$filename\"\) 2>&1 | tee rec.log