Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-25 08:29:08

0001 #!/usr/bin/env bash
0002 
0003 MIN_ARG_COUNT=2
0004 MAX_ARG_COUNT=3
0005 if [ "$#" -lt "$MIN_ARG_COUNT" ] || [ "$#" -gt "$MAX_ARG_COUNT" ] ; then
0006     echo "Unsupported call:"
0007     echo $0 $@
0008     echo Abort.
0009     exit 0
0010 fi
0011 
0012 filename=${1}
0013 destination=${2}
0014 dbid=${3:--1} # dbid for faster db lookup, -1 means no dbid
0015 if [ $dbid -eq -1 ] || [ $dbid -eq 0 ]; then
0016     # I don't quite understand why dbid can be 0, need to dig around --> later
0017     # Fallback (or rather default): Use environment variable exported by wrapper
0018     dbid=${PRODDB_DBID:--1}
0019 fi
0020 
0021 if [ ! -f ${filename} ]; then
0022     echo "${filename} not found!"
0023     echo ls -lahtr
0024     ls -lahtr
0025     exit 0
0026 fi
0027 
0028 # Could test the destination like this, but we want to minimize lustre probing in the worker jobs
0029 # if [ -d "$destination" ]; then   echo "$DIRECTORY does exist." ; else exit 1; fi
0030 
0031 # Number of events and first/last event numbers
0032 rm -f numbers.txt  cleannumbers.txt
0033 root.exe -l -b -q GetEntriesAndEventNr.C\(\"${filename}\"\) > numbers.txt
0034 tail -n 3  numbers.txt  | awk '{print $NF}' > cleannumbers.txt
0035 
0036 nevents=`sed -n '1p' cleannumbers.txt`
0037 first=`sed -n '2p' cleannumbers.txt`
0038 last=`sed -n '3p' cleannumbers.txt`
0039 
0040 # Set to -1 if empty or 0
0041 nevents=${nevents:--1}
0042 first=${first:--1}
0043 last=${last:--1}
0044 
0045 echo cat numbers.txt
0046 cat numbers.txt
0047 echo cat cleannumbers.txt
0048 cat cleannumbers.txt
0049 rm -f numbers.txt cleannumbers.txt
0050 
0051 # md5sum:
0052 md5=`/usr/bin/env md5sum ${filename} | cut -d ' ' -f 1`
0053 
0054 # size and ctime
0055 #stat -c '%s %Y'
0056 size=`stat -c '%s' ${filename}`
0057 ctime=`stat -c '%Y' ${filename}`
0058 
0059 #change the destination filename
0060 destname=`basename ${filename}`
0061 destname="${destname}:nevents:${nevents}"
0062 destname="${destname}:first:${first}"
0063 destname="${destname}:last:${last}"
0064 destname="${destname}:md5:${md5}"
0065 destname="${destname}:size:${size}"
0066 destname="${destname}:ctime:${ctime}"
0067 destname="${destname}:dbid:${dbid}"
0068 
0069 action="dd if=${filename} of=${destination}/${destname} bs=12MB && rm -v ${filename}"
0070 # action="cp -v ${filename} ${destination}/${destname} && rm -v ${filename}"
0071 echo ${action}
0072 echo
0073 eval ${action}
0074 
0075 exit 0 # Fom Jason: stageout should never propagate a failed error code