#!/bin/sh # # ======================================================================== # # * # * This file is part of MARS, the MAGIC Analysis and Reconstruction # * Software. It is distributed to you in the hope that it can be a useful # * and timesaving tool in analysing Data of imaging Cerenkov telescopes. # * It is distributed WITHOUT ANY WARRANTY. # * # * Permission to use, copy, modify and distribute this software and its # * documentation for any purpose is hereby granted without fee, # * provided that the above copyright notice appear in all copies and # * that both that copyright notice and this permission notice appear # * in supporting documentation. It is provided "as is" without express # * or implied warranty. # * # # # Author(s): Daniela Dorner 08/2004 # # Copyright: MAGIC Software Development, 2000-2004 # # # ======================================================================== # # user=`whoami` source /home/$user/Mars/datacenter/scripts/sourcefile table=RunProcessStatus column=fTimingCorrection date=NULL datetime=`date +%F_%T` year=`date +%Y` getstatuslogpath=$logpath/getstatus/correct_raw_time/$year getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log makedir $getstatuslogpath >> $scriptlog 2>&1 if [ -e $listpath/ToDo-$table-$column.txt ] then echo "correct_raw_time is already running -> exit" exit fi cd $mars echo "getting list..." check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'` case $check0 in 1) echo "check0=$check0 -> everything ok -> run correct_raw_time";; *) echo "check0=$check0 -> ERROR -> step has to be repeated";; esac runs=(`cat $listpath/ToDo-$table-$column.txt`) if [ "$runs" = "" ] then echo "nothing to do -> exit" rm -v $listpath/ToDo-$table-$column.txt exit fi echo "runs: "${runs[@]} for run in ${runs[@]} do echo "getting path for run $run ... " infile=`find $datapath/rawfiles-wrong-timing/ -name *${run}_[D,C,P,S]_*` echo "infile:"$infile outfile=`echo $infile | sed -e 's/-wrong-timing//g'` echo "outfile:"$outfile outpath=`dirname $outfile` echo "outpath:"$outpath makedir $outpath timecorrpath=$outpath"/timecorrlogs" echo "timecorrpath: "$timecorrpath make dir $timecorrpath check1=0 echo "run correct_raw_time..." /home/tape/MagicReadout/correct_raw_time $infile $outfile > $timecorrpath/correct_raw_time-$run.log check1=$? case $check1 in 1) echo "check1=$check1 -> everything ok -> setting status..." no=`printf %08d $run | cut -c 1-5` setstatuspath=$logpath/setstatus/correct_raw_time/$no echo "setstatuspath: "$setstatuspath makedir $setstatuspath check2=`root -q -b $macrospath/setstatus.C+\("\"$run\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuspath/setstatus-correct_raw_time-$run.log | grep int | sed -e 's/(int)//'` case $check2 in 0) echo "check2=0 -> ERROR -> step could not be set";; 1) echo "check2=1 -> everything ok, status has been set";; esac ;; *) echo "check1=$check1 -> ERROR -> step has to be repeated";; esac done rm -v $listpath/ToDo-$table-$column.txt