| 1 | #!/bin/sh
|
|---|
| 2 | #
|
|---|
| 3 | # ========================================================================
|
|---|
| 4 | #
|
|---|
| 5 | # *
|
|---|
| 6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 7 | # * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 9 | # * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 10 | # *
|
|---|
| 11 | # * Permission to use, copy, modify and distribute this software and its
|
|---|
| 12 | # * documentation for any purpose is hereby granted without fee,
|
|---|
| 13 | # * provided that the above copyright notice appear in all copies and
|
|---|
| 14 | # * that both that copyright notice and this permission notice appear
|
|---|
| 15 | # * in supporting documentation. It is provided "as is" without express
|
|---|
| 16 | # * or implied warranty.
|
|---|
| 17 | # *
|
|---|
| 18 | #
|
|---|
| 19 | #
|
|---|
| 20 | # Author(s): Daniela Dorner 12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
|
|---|
| 21 | #
|
|---|
| 22 | # Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | #
|
|---|
| 28 |
|
|---|
| 29 | user=`whoami`
|
|---|
| 30 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
|---|
| 31 |
|
|---|
| 32 | set -C
|
|---|
| 33 |
|
|---|
| 34 | scriptlogpath=$logpath/run/mcsequences/`date +%Y/%m/%d`
|
|---|
| 35 | makedir $scriptlogpath
|
|---|
| 36 | scriptlog=$scriptlogpath/mcsequences`date +%F`.log
|
|---|
| 37 |
|
|---|
| 38 | date >> $scriptlog 2>&1
|
|---|
| 39 |
|
|---|
| 40 | lockfile=$lockpath/lock-mcsequences.txt
|
|---|
| 41 | date > $lockfile >> $scriptlog 2>&1
|
|---|
| 42 | checklock0=$?
|
|---|
| 43 | case $checklock0 in
|
|---|
| 44 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
|---|
| 45 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
|---|
| 46 | echo "-> linkmc is running -> exit" >> $scriptlog 2>&1
|
|---|
| 47 | date >> $scriptlog 2>&1
|
|---|
| 48 | exit;;
|
|---|
| 49 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 50 | esac
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | mcpath=/montecarlo/rawfiles
|
|---|
| 54 | mcsequpath=/montecarlo/sequences
|
|---|
| 55 |
|
|---|
| 56 | dirs=`find $mcpath -type d`
|
|---|
| 57 |
|
|---|
| 58 | for dir in ${dirs[@]}
|
|---|
| 59 | do
|
|---|
| 60 | cont=`echo $dir | cut -d/ -f6`
|
|---|
| 61 | if [ "$cont" == "" ]
|
|---|
| 62 | then
|
|---|
| 63 | continue
|
|---|
| 64 | fi
|
|---|
| 65 | echo $dir >> $scriptlog 2>&1
|
|---|
| 66 | files=`ls $dir`
|
|---|
| 67 | calfile=`find $dir -name *_C_*`
|
|---|
| 68 | pedfile=`find $dir -name *_P_*`
|
|---|
| 69 | calrun=`echo $calfile | cut -d_ -f2`
|
|---|
| 70 | pedrun=`echo $pedfile | cut -d_ -f2`
|
|---|
| 71 | datruns=`find $dir -name *_D_* | cut -d_ -f2 | tr "\n" " "`
|
|---|
| 72 | # workaround due to 5digit runnumber for data with runnumber < 35487
|
|---|
| 73 | # firstrun=`echo $datruns | cut -c 0-8`
|
|---|
| 74 | firstrun=`echo $datruns | cut -c 0-5 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g'`
|
|---|
| 75 | date=`echo $dir | cut -c 22-31 | sed -e 's/\//-/g'`
|
|---|
| 76 |
|
|---|
| 77 | # workaround due to 5digit runnumber for data with runnumber < 35487
|
|---|
| 78 | # no=`echo $firstrun | cut -c 0-4`
|
|---|
| 79 | no=`printf %08d $firstrun | cut -c 0-4`
|
|---|
| 80 | no2=`printf %08d $firstrun`
|
|---|
| 81 | sequpath=$mcsequpath/$no
|
|---|
| 82 | makedir $sequpath >> $scriptlog 2>&1
|
|---|
| 83 | # sequfile=$sequpath/sequence$firstrun.txt
|
|---|
| 84 | sequfile=$sequpath/sequence$no2.txt
|
|---|
| 85 | echo "writing sequfile "$sequfile >> $scriptlog 2>&1
|
|---|
| 86 |
|
|---|
| 87 | echo "Sequence: $firstrun" > $sequfile
|
|---|
| 88 | echo "Night: $date" >> $sequfile
|
|---|
| 89 | echo "" >> $sequfile
|
|---|
| 90 | echo "CalRuns: $calrun" >> $sequfile
|
|---|
| 91 | echo "PedRuns: $pedrun" >> $sequfile
|
|---|
| 92 | echo "DatRuns: $datruns" >> $sequfile
|
|---|
| 93 | echo "" >> $sequfile
|
|---|
| 94 | done
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 98 |
|
|---|
| 99 | set +C
|
|---|
| 100 |
|
|---|
| 101 | date >> $scriptlog 2>&1
|
|---|
| 102 |
|
|---|