]> git.uio.no Git - u/mrichter/AliRoot.git/blob - test/cosmic/rec.sh
Updated verison using only gshell (Marco)
[u/mrichter/AliRoot.git] / test / cosmic / rec.sh
1 #!/bin/sh
2 #############################################################################
3 # rec.sh. Front-end script to run reconstruction from the grid chunks
4 # Usage:
5 #    ./rec.sh <run_number>
6 #############################################################################
7 #
8 # modification history
9 # version 1.0  2008/03/04 02:12  Marco Meoni
10 #
11 # version 1.1  2008/03/28 00:33  Marco Meoni. Used aliensh instead of alien client
12
13 # SET THE FOLLOWING PARAMETERS IF NEEDED: 
14 # ---------------------------------------
15 YEAR=08
16 DIALOG=${DIALOG=dialog}
17 GSHELL_ROOT=$ALIEN_ROOT/api
18 PATH=$PATH:$GSHELL_ROOT/bin
19 # ---------------------------------------
20
21 RUNNUM=$1
22
23 [ -z $RUNNUM ] && { echo "Please provide a run number..."; exit 1; }
24
25 [ ! -e "$HOME/.globus/usercert.pem" ] && { echo "FAILED: There is no certificate in $HOME/.globus"; exit 1; }
26
27 [ -e "/tmp/gclient_env_$UID" ] && { source /tmp/gclient_env_$UID; }
28 alien-token-init 
29
30 [ ! "$?" -eq "0" ] && { echo "FAILED: Token creation failed"; exit 1; }
31
32 VERSION=1.0
33 TITLE="Standalone reconstruction of Grid rawdata chunks. v$VERSION"
34
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
39
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`
43 rm -f collection.tmp
44
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 \
49         $list 2> $tempfile
50
51 CHUNKS=`cat $tempfile`" ."
52 echo "Selected chunks:"
53 echo $CHUNKS
54 echo
55
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-`
59
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
63      cd       $RUNNUM"/"$CHUNK
64      aliroot -b -q ../../rec.C\(\"alien://$filename\"\) 2>&1 | tee rec.log
65      cd ../..
66 done