2 #############################################################################
3 # prepareCollection.sh. Script to prepare a raw-data chunks collection
6 # ./prepareCollection.sh <run_number> <collection_file>
7 #############################################################################
10 # version 1.0 2008/09/12 Cvetan Cheshkov
12 # SET THE FOLLOWING PARAMETERS IF NEEDED:
13 # ---------------------------------------
15 # ---------------------------------------
19 [ -z $RUNNUM ] && { echo "Please provide a run number..."; exit 1; }
23 [ -z $OUTFILE ] && { echo "Please provide an output filename..."; 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; }
32 # Retrieve the list of chunks from AliEn.......
33 BASEDIR="/alice/data/20"$YEAR
34 PATTERN="/raw/"$YEAR"0000"$RUNNUM"*0.root"
36 gbbox find $BASEDIR $PATTERN | grep -v found | head --lines=-1 > collection.tmp
38 [ $(stat -c%s collection.tmp) -eq 0 ] && { echo "No chunks found for the given run"; exit 1; }
41 for ifile in `cat collection.tmp` ; do echo "alien://$ifile" >> $OUTFILE 2>&1; done
44 echo `cat $OUTFILE | wc -l`" raw-data chunks are found and added to the collection file "$OUTFILE;