<commit_before>#!/bin/sh
#############################################################################
# rec.sh. Front-end script to run reconstruction from the grid chunks
# Usage:
#    ./rec.sh <run_number>
#############################################################################
#
# modification history
# version 1.0  2008/03/04 02:12  <NAME>
#
# version 1.1  2008/03/28 00:33  <NAME>. Used aliensh instead of alien client

# SET THE FOLLOWING PARAMETERS IF NEEDED: 
# ---------------------------------------
YEAR=08
DIALOG=${DIALOG=dialog}
GSHELL_ROOT=$ALIEN_ROOT/api
PATH=$PATH:$GSHELL_ROOT/bin
# ---------------------------------------

RUNNUM=$1

[ -z $RUNNUM ] && { echo "Please provide a run number..."; exit 1; }

[ ! -e "$HOME/.globus/usercert.pem" ] && { echo "FAILED: There is no certificate in $HOME/.globus"; exit 1; }

[ -e "/tmp/gclient_env_$UID" ] && { source /tmp/gclient_env_$UID; }
alien-token-init 

[ ! "$?" -eq "0" ] && { echo "FAILED: Token creation failed"; exit 1; }

VERSION=1.0
TITLE="Standalone reconstruction of Grid rawdata chunks. v$VERSION"

# Retrieve the list of chunks from AliEn.......
BASEDIR="/alice/data/20"$YEAR
PATTERN="/raw/"$YEAR"0000"$RUNNUM"*0.root"
aliensh -c "gbbox find $BASEDIR $PATTERN" | head --lines=-1 > collection.tmp

[ $(stat -c%s collection.tmp) -eq 0 ] && { echo "No chunks found for the given run"; exit 1; }
list=`cat collection.tmp | awk '{printf("%s %s %s ",$1,"  .","0");}'`   # improve: put basename
totChunks=`cat collection.tmp | wc -l`; totChunks=`echo \($totChunks / 3\) | bc`
rm -f collection.tmp

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15
$DIALOG --clear --no-cancel --title "$TITLE" \
        --ok-label OK --checklist "$totChunks chunks available. Select chunks for reconstruction" 18 74 10 \
        $list 2> $tempfile

CHUNKS=`cat $tempfile`" ."
echo "Selected chunks:"
echo $CHUNKS
echo

echo $CHUNKS | while read -d " " filename; do 
     filename=${filename//\"/} 
     CHUNK=`echo $filename | cut -d "/" -f 8 | cut -d "." -f 1,2 | cut -c 12-14,16-`

     echo "Running AliRoot reconstruction for chunk $filename. Outputs will be stored in "$RUNNUM"/"$CHUNK"."
     rm -rf   $RUNNUM"/"$CHUNK
     mkdir -p $RUNNUM"/"$CHUNK
     cd       $RUNNUM"/"$CHUNK
     aliroot -b -q ../../rec.C\(\"alien://$filename\"\) 2>&1 | tee rec.log
     cd ../..
done<commit_msg>Fixes applied to the release version<commit_after>#!/bin/sh
#############################################################################
# rec.sh. Front-end script to run reconstruction from the grid chunks
# Usage:
#    ./rec.sh <run_number>
#############################################################################
#
# modification history
# version 1.0  2008/03/04 02:12  <NAME>
#
# version 1.1  2008/03/28 00:33  <NAME>. Used aliensh instead of alien client

# SET THE FOLLOWING PARAMETERS IF NEEDED: 
# ---------------------------------------
YEAR=08
DIALOG=/usr/bin/dialog
# ---------------------------------------

RUNNUM=$1

[ -z $RUNNUM ] && { echo "Please provide a run number..."; exit 1; }

[ ! -e "$HOME/.globus/usercert.pem" ] && { echo "FAILED: There is no certificate in $HOME/.globus"; exit 1; }

[ -e "/tmp/gclient_env_$UID" ] && { source /tmp/gclient_env_$UID; }
alien-token-init 

[ ! "$?" -eq "0" ] && { echo "FAILED: Token creation failed"; exit 1; }

VERSION=1.0
TITLE="Standalone reconstruction of Grid rawdata chunks. v$VERSION"

# Retrieve the list of chunks from AliEn.......
BASEDIR="/alice/data/20"$YEAR
PATTERN="/raw/"$YEAR"0000"$RUNNUM"*0.root"
aliensh -c "gbbox find $BASEDIR $PATTERN" | head --lines=-1 > collection.tmp

[ $(stat -c%s collection.tmp) -eq 0 ] && { echo "No chunks found for the given run"; exit 1; }
rm -r collection.tmp2
for ifile in `cat collection.tmp | head --lines=500` ; do printf $ifile" "\|" "0" " >> collection.tmp2 ; done
list=`cat collection.tmp2`
rm -f collection.tmp2 
totChunks=`cat collection.tmp | wc -l`
rm -f collection.tmp

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15
$DIALOG --clear --no-cancel --title "$TITLE" \
        --ok-label OK --checklist "$totChunks chunks available for run $RUNNUM (only the first 500 are shown). Select chunks for reconstruction" 18 80 10 \
        $list 2> $tempfile

CHUNKS=`cat $tempfile`
echo "Selected chunks:"
echo $CHUNKS
echo

$DIALOG --clear --no-cancel \
        --ok-label OK --radiolist "Program to run:" 15 20 5 "aliroot -b" \| on alieve \| off 2> $tempfile
PROGRAM=`cat $tempfile`
 
for filename in $CHUNKS; do
     filename=${filename//\"/} 
     CHUNK=`basename $filename | cut -d "." -f 1,2`

     echo "Running AliRoot reconstruction for chunk $filename. Outputs will be stored in "$RUNNUM"/"$CHUNK"."
     rm -rf   $RUNNUM"/"$CHUNK
     mkdir -p $RUNNUM"/"$CHUNK
     cd       $RUNNUM"/"$CHUNK
     $PROGRAM -q $ALICE_ROOT/test/cosmic/rec.C\(\"alien://$filename\"\) 2>&1 | tee rec.log
     cd ../..
done
{'fraction_non_alphanumeric': 0.24984888172476324, 'fraction_numerical': 0.03163409228289341, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3349201', 'n_tokens_mistral': 1823, 'n_tokens_neox': 1666, 'n_words': 496}