source: trunk/MagicSoft/Mars/datacenter/scripts/correcttime@ 7465

Last change on this file since 7465 was 7465, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.4 KB
Line 
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 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2006
23#
24#
25# ========================================================================
26#
27# This script runs the timing correction for all run, that need the timing
28# correction
29#
30# After checking, if the script is already running, the todolist is
31# written by using the macro getdolist.C
32# Then for each run the timing correction is done
33# If this was successful, the status is inserted into the database using
34# the macro setstatus.C
35#
36# This script was needed for the data between 06/2004 and 02/2005 (including
37# this months).
38#
39
40user=`whoami`
41program=correct_raw_time
42source /home/$user/Mars/datacenter/scripts/sourcefile
43
44table=RunProcessStatus
45column=fTimingCorrection
46date=NULL
47datetime=`date +%F_%T`
48year=`date +%Y`
49
50getstatuslogpath=$logpath/getstatus/$program/$year
51getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
52makedir $getstatuslogpath >> $scriptlog 2>&1
53
54if [ -e $listpath/ToDo-$table-$column.txt ]
55then
56 echo "$program is already running -> exit"
57 exit
58fi
59
60cd $mars
61
62echo "getting list..."
63check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
64
65case $check0 in
66 1) echo "check0=$check0 -> everything ok -> run $program";;
67 *) echo "check0=$check0 -> ERROR -> step has to be repeated";;
68esac
69
70# retrieving runs from todo file
71runs=(`cat $listpath/ToDo-$table-$column.txt`)
72if [ "$runs" = "" ]
73then
74 echo "nothing to do -> exit"
75 rm -v $listpath/ToDo-$table-$column.txt
76 exit
77fi
78
79echo "runs: "${runs[@]}
80for run in ${runs[@]}
81do
82 echo "getting path for run $run ... "
83 infile=`find $datapath/rawfiles-wrong-timing/ -name *${run}_[D,C,P,S]_*`
84 echo "infile:"$infile
85 outfile=`echo $infile | sed -e 's/-wrong-timing//g'`
86 echo "outfile:"$outfile
87 outpath=`dirname $outfile`
88 echo "outpath:"$outpath
89 makedir $outpath
90
91 timecorrpath=$outpath"/timecorrlogs"
92 echo "timecorrpath: "$timecorrpath
93 makedir $timecorrpath
94
95 check1=0
96 echo "run $program..."
97 /home/tape/MagicReadout/correct_raw_time $infile $outfile > $timecorrpath/$program-$run.log
98 check1=$?
99
100 case $check1 in
101 1) echo "check1=$check1 -> everything ok -> setting status..."
102 no=`printf %08d $run | cut -c 1-5`
103 statustime="Now()"
104 failed="NULL"
105 starttime="NULL"
106 failedtime="NULL"
107 var1=$no
108 var2=$run
109 setstatus
110 ;;
111 *) echo "check1=$check1 -> ERROR -> step has to be repeated";;
112 esac
113done
114
115rm -v $listpath/ToDo-$table-$column.txt
116
Note: See TracBrowser for help on using the repository browser.