Wednesday, July 28, 2010

simple csh script

################################### Version 0.9
#!/bin/csh
cd ~/selector
@ i = 0
foreach file (../root/981AF*.root)
    root4star -q -b runD0Analysis.C\(\"$file\"\)
    if ($i == 0) then
        mv histManager.root tmp.root
    else
        hadd tmp.root histManager.root OutFile.root
    endif
    mv tmp.root OutFile.root
    @ i++
end





################################### Version 1.0
#!/bin/csh
## Run script for D0Analysis selector
## Created by Kunsu OH, 2010.07.27
starver SL10c

setenv RUN  `date --date 'today' +%Y%m%d_%H%M`
setenv SEL_HOME `pwd`

mkdir $RUN
mkdir $RUN/src

cp src/D0Analysis.C src/D0Analysis.h src/runD0Analysis.C src/histManager.cxx src/histManager.h $RUN/src

echo $RUN > $RUN/log
@ i = 0

foreach file (/star/u/kunsu/data05/D0/P10ic/7B3B7278518AE8DEE2E940F7529DBE0C_*.root)
cd $SEL_HOME/$RUN/src
echo '==================================' $i '========================================' >>& ../log
root4star -q -b -l runD0Analysis.C\(\"$file\"\) >>& ../log
if ($i == 0) then
mv histManager.root tmp.root
else
hadd tmp.root histManager.root .OutFile.root >>& ../log
endif
mv tmp.root .OutFile.root
@ i++
end
cp .OutFile.root ../outfile.root
cd $SEL_HOME
echo 'Finish!!@'





http://coffeenix.net/doc/shell_programming/shell346.html



No comments:

Post a Comment